-
Notifications
You must be signed in to change notification settings - Fork 418
feat: Add staging OTel log synthesis rule for POSTGRESQLINSTANCE #3074
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
Open
mraju1
wants to merge
1
commit into
newrelic:main
Choose a base branch
from
mraju1:mr-postgres-add-otel-logs-rule
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| domain: INFRA | ||
| type: POSTGRESQLINSTANCE | ||
|
|
||
| synthesis: | ||
| rules: | ||
| # opentelemetry (postgresqlreceiver); service.instance.id is host:port, enabled by default | ||
| - ruleName: infra_postgresqlinstance_service_instance_id | ||
| identifier: service.instance.id # host:port | ||
| name: service.instance.id | ||
| encodeIdentifierInGUID: true | ||
| conditions: | ||
| - attribute: eventType | ||
| value: Metric | ||
| - attribute: metricName | ||
| prefix: postgresql. | ||
| - attribute: instrumentation.provider | ||
| value: opentelemetry | ||
| tags: | ||
| # Environment resource attributes | ||
| host.type: | ||
| cloud.provider: | ||
| cloud.account.id: | ||
| cloud.region: | ||
| otel.library.name: | ||
| entityTagName: instrumentation.name | ||
|
|
||
| # opentelemetry logs (db.server.top_query / db.server.query_sample); | ||
| # db.system.name is always present on these log events when enabled. | ||
| # Using service.instance.id (host:port) to match the metric rule above. | ||
| - ruleName: infra_postgresqlinstance_otel_logs | ||
| identifier: service.instance.id # host:port | ||
| name: service.instance.id | ||
| encodeIdentifierInGUID: true | ||
| conditions: | ||
| - attribute: eventType | ||
| value: Log | ||
| - attribute: instrumentation.provider | ||
| value: opentelemetry | ||
| - attribute: db.system.name | ||
| value: postgresql | ||
| tags: | ||
| host.type: | ||
| cloud.provider: | ||
| cloud.account.id: | ||
| cloud.region: | ||
| otel.library.name: | ||
| entityTagName: instrumentation.name | ||
|
|
||
| # nri-postgresql / PostgresqlInstanceSample | ||
| - ruleName: infra_postgresqlinstance_entityId | ||
| identifier: entityId | ||
| name: entityKey | ||
| legacyFeatures: | ||
| useNonStandardAttributes: true | ||
| overrideGuidType: true | ||
| prefixedTags: | ||
| label.: | ||
| ttl: PT4H | ||
| conditions: | ||
| - attribute: eventType | ||
| value: 'PostgresqlInstanceSample' | ||
| tags: | ||
| integrationName: | ||
| ttl: P1D | ||
| integrationVersion: | ||
| ttl: P1D | ||
| reportingAgent: | ||
| ttl: P1D | ||
| reportingEndpoint: | ||
| ttl: P1D | ||
|
|
||
| tags: | ||
| # For OpenTelemetry | ||
| telemetry.sdk.name: | ||
| entityTagName: instrumentation.provider | ||
|
|
||
| goldenTags: | ||
| - postgres.host | ||
| configuration: | ||
| entityExpirationTime: DAILY | ||
| alertable: true | ||
|
|
||
| dashboardTemplates: | ||
| # This should match the entity created from the ohi in the infra pipeline | ||
| newRelic: | ||
| template: newrelic_dashboard.json | ||
| opentelemetry: | ||
| template: opentelemetry_dashboard.json | ||
|
|
||
| ownership: | ||
| primaryOwner: | ||
| teamName: "Database Integrations" | ||
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,35 @@ | ||
| [ | ||
| { | ||
| "eventType": "Log", | ||
| "instrumentation.provider": "opentelemetry", | ||
| "db.system.name": "postgresql", | ||
| "db.namespace": "testdb", | ||
| "db.query.text": "SELECT 1", | ||
| "event.name": "db.server.top_query", | ||
| "service.instance.id": "localhost:5432", | ||
| "newrelic.source": "api.logs.otlp", | ||
| "otel.library.name": "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver", | ||
| "postgresql.calls": 10, | ||
| "postgresql.queryid": "12345", | ||
| "postgresql.rolname": "app_user", | ||
| "postgresql.rows": 100, | ||
| "postgresql.total_exec_time": 5.2, | ||
| "timestamp": 1784408557426 | ||
| }, | ||
| { | ||
| "eventType": "Log", | ||
| "instrumentation.provider": "opentelemetry", | ||
| "db.system.name": "postgresql", | ||
| "db.namespace": "testdb", | ||
| "db.query.text": "SELECT id FROM users WHERE active = $1", | ||
| "event.name": "db.server.query_sample", | ||
| "service.instance.id": "localhost:5432", | ||
| "newrelic.source": "api.logs.otlp", | ||
| "otel.library.name": "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver", | ||
| "postgresql.state": "active", | ||
| "postgresql.pid": 1234, | ||
| "postgresql.rolname": "app_user", | ||
| "postgresql.total_exec_time": 1.5, | ||
| "timestamp": 1784408557426 | ||
| } | ||
| ] |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mraju1 Can we update the tags for both metrics and logs?
otel.library.versionso we can identify customer collector versions.host.type, cloud.provider, cloud.account.id, and cloud.regionsince they aren't present in the PostgreSQL receiver's metadata.yaml.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are useful tags.
They are coming from the resourcedetectionprocessor and are all very popular.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nr-ksteinbach Thanks for the clarification!
One thing worth flagging though,
resourcedetectionprocessoractually detects the collector's own VM/host, not the database's. It reads from the collector's local environment (EC2/GCP/Azure/system metadata).So these tags are accurate only when the collector runs on the same VM as Postgres. If it runs on a separate VM (e.g. a
centralized collector, or amanaged/remote Postgres instance),host.type, cloud.provider, cloud.account.id, and cloud.regionwould describe the collector's VM, not the DB's - which could be misleading onPOSTGRESQLINSTANCE.Given that's a pretty common setup, I'd lean toward dropping them. Happy to hear your thoughts on this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a value for the a tag attribute entry is not present, does it ignore tagging it or creates a tag with empty value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mraju1 As per the synthesis docs: a tag is only created if the attribute is present on the matching data point. If it's absent, no tag gets written (not an empty-value tag).
So keeping
host.type/cloud.provider/etc.in the rule is safe when the attribute is missing - the real risk we were discussing is only when the attribute is present but describes the wrong VM (collector's, not the DB's).Also, can you please fix the errors thrown by entityBot?