-
Notifications
You must be signed in to change notification settings - Fork 80
feat: Update Elasticsearch json parser to use LoggingReceiverMacro
#1987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
franciscovalentecastro
merged 12 commits into
GoogleCloudPlatform:master
from
dyl10s:feat/elasticsearch-json-refactor
Jul 28, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
17cfa85
generated test files
dyl10s 5315299
refactored elasticsearch json
dyl10s b603b9a
removed double comments
dyl10s b3b6f00
move elasticsearch processor init to transform tests only
dyl10s 992497f
updated to use ReceiverMixin
dyl10s b16bece
removed duplicate import
dyl10s 6e92c31
Merge branch 'master' into feat/elasticsearch-json-refactor
franciscovalentecastro 79aeb34
Merge branch 'master' into feat/elasticsearch-json-refactor
dyl10s 5d4df4e
Merge branch 'feat/elasticsearch-json-refactor' of https://github.com…
dyl10s 025d223
updated yaml tags
dyl10s a483257
Merge branch 'master' into feat/elasticsearch-json-refactor
franciscovalentecastro d948e68
Merge branch 'master' into feat/elasticsearch-json-refactor
franciscovalentecastro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
transformation_test/testdata/logging_processor-elasticsearch-json/config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - type: elasticsearch_json |
15 changes: 15 additions & 0 deletions
15
transformation_test/testdata/logging_processor-elasticsearch-json/input.log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| {"type": "server", "timestamp": "2024-06-10T12:34:56,789Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "elasticsearch", "node.name": "node-1", "message": "starting ..."} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:00,321Z", "level": "WARN", "component": "o.e.d.z.ZenDiscovery", "node.name": "node-1", "message": "failed to connect to master", "user.run_by.name": "admin", "event.action": "connect"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:10,123Z", "level": "ERROR", "component": "o.e.b.Bootstrap", "node.name": "node-1", "message": "Exception", "error.type": "java.lang.IllegalStateException", "error.message": "failed to obtain node locks"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:15,456Z", "level": "DEBUG", "component": "o.e.n.Node", "node.name": "node-1", "message": "stopping ..."} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:16,789Z", "level": "TRACE", "component": "o.e.n.Node", "node.name": "node-1", "message": "stopped"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:17,123Z", "level": "DEPRECATION", "component": "o.e.n.Node", "node.name": "node-1", "message": "deprecated setting used"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:18,456Z", "level": "CRITICAL", "component": "o.e.n.Node", "node.name": "node-1", "message": "critical error occurred"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:19,456Z", "level": "FATAL", "component": "o.e.n.Node", "node.name": "node-1", "message": "fatal error occurred"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:20,456Z", "level": "UNKNOWN", "component": "o.e.n.Node", "node.name": "node-1", "message": "unknown log level"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:21,456Z", "level": "INFO", "message": "missing component and node name"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:22,456Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "elasticsearch", "message": "missing node name"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:23,456Z", "level": "INFO", "component": "o.e.n.Node", "node.name": "node-1", "message": "missing cluster name"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:24,456Z", "level": "INFO", "component": "o.e.n.Node", "node.name": "node-1", "message": "nested fields", "user.run_by.name": "testuser", "authentication.token.id": "abc123"} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:25,456Z", "level": "ERROR", "component": "o.e.b.ElasticsearchUncaughtExceptionHandler", "node.name": "node-1", "message": "uncaught exception in thread [main]", "stacktrace": ["org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: unknown setting [invalid.key]", "at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:166)", "... 6 more"]} | ||
| {"type": "server", "timestamp": "2024-06-10T12:35:26,456Z", "level": "INFO", "component": "o.e.n.Node", "node.name": "node-1", "message": "invalid timestamp", "timestamp": "not-a-timestamp"} |
201 changes: 201 additions & 0 deletions
201
transformation_test/testdata/logging_processor-elasticsearch-json/output_fluentbit.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| - entries: | ||
|
||
| - jsonPayload: | ||
| cluster: | ||
| name: elasticsearch | ||
| component: o.e.n.Node | ||
| level: INFO | ||
| message: starting ... | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 200.0 | ||
| timestamp: 2024-06-10T12:34:56.789000000Z | ||
| - jsonPayload: | ||
| component: o.e.d.z.ZenDiscovery | ||
| event: | ||
| action: connect | ||
| level: WARN | ||
| message: failed to connect to master | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| user: | ||
| run_by: | ||
| name: admin | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 400.0 | ||
| timestamp: 2024-06-10T12:35:00.321000000Z | ||
| - jsonPayload: | ||
| component: o.e.b.Bootstrap | ||
| error.message: failed to obtain node locks | ||
| error.type: java.lang.IllegalStateException | ||
| level: ERROR | ||
| message: Exception | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 500.0 | ||
| timestamp: 2024-06-10T12:35:10.123000000Z | ||
| - jsonPayload: | ||
| component: o.e.n.Node | ||
| level: DEBUG | ||
| message: stopping ... | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 100.0 | ||
| timestamp: 2024-06-10T12:35:15.456000000Z | ||
| - jsonPayload: | ||
| component: o.e.n.Node | ||
| level: TRACE | ||
| message: stopped | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 100.0 | ||
| timestamp: 2024-06-10T12:35:16.789000000Z | ||
| - jsonPayload: | ||
| component: o.e.n.Node | ||
| level: DEPRECATION | ||
| message: deprecated setting used | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 400.0 | ||
| timestamp: 2024-06-10T12:35:17.123000000Z | ||
| - jsonPayload: | ||
| component: o.e.n.Node | ||
| level: CRITICAL | ||
| message: critical error occurred | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 500.0 | ||
| timestamp: 2024-06-10T12:35:18.456000000Z | ||
| - jsonPayload: | ||
| component: o.e.n.Node | ||
| level: FATAL | ||
| message: fatal error occurred | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 600.0 | ||
| timestamp: 2024-06-10T12:35:19.456000000Z | ||
| - jsonPayload: | ||
| component: o.e.n.Node | ||
| level: UNKNOWN | ||
| message: unknown log level | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| timestamp: 2024-06-10T12:35:20.456000000Z | ||
| - jsonPayload: | ||
| level: INFO | ||
| message: missing component and node name | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 200.0 | ||
| timestamp: 2024-06-10T12:35:21.456000000Z | ||
| - jsonPayload: | ||
| cluster: | ||
| name: elasticsearch | ||
| component: o.e.n.Node | ||
| level: INFO | ||
| message: missing node name | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 200.0 | ||
| timestamp: 2024-06-10T12:35:22.456000000Z | ||
| - jsonPayload: | ||
| component: o.e.n.Node | ||
| level: INFO | ||
| message: missing cluster name | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 200.0 | ||
| timestamp: 2024-06-10T12:35:23.456000000Z | ||
| - jsonPayload: | ||
| authentication: | ||
| token: | ||
| id: abc123 | ||
| component: o.e.n.Node | ||
| level: INFO | ||
| message: nested fields | ||
| node: | ||
| name: node-1 | ||
| type: server | ||
| user: | ||
| run_by: | ||
| name: testuser | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 200.0 | ||
| timestamp: 2024-06-10T12:35:24.456000000Z | ||
| - jsonPayload: | ||
| component: o.e.b.ElasticsearchUncaughtExceptionHandler | ||
| level: ERROR | ||
| message: uncaught exception in thread [main] | ||
| node: | ||
| name: node-1 | ||
| stacktrace: | ||
| - "org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: unknown setting [invalid.key]" | ||
| - at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:166) | ||
| - ... 6 more | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 500.0 | ||
| timestamp: 2024-06-10T12:35:25.456000000Z | ||
| - jsonPayload: | ||
| component: o.e.n.Node | ||
| level: INFO | ||
| message: invalid timestamp | ||
| node: | ||
| name: node-1 | ||
| timestamp: not-a-timestamp | ||
| type: server | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/elasticsearch_json | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 200.0 | ||
| timestamp: 2024-06-10T12:35:26.456000000Z | ||
| partialSuccess: true | ||
| resource: | ||
| labels: {} | ||
| type: gce_instance | ||
1 change: 1 addition & 0 deletions
1
transformation_test/testdata/logging_processor-elasticsearch-json/output_otel.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - config_error: "failed generating OTel processor: &confgenerator.loggingProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroElasticsearchJson]{ConfigComponent:confgenerator.ConfigComponent{Type:\"elasticsearch_json\"}, ProcessorMacro:apps.LoggingProcessorMacroElasticsearchJson{}}, err: unimplemented" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.