Skip to content

Introduce OTel Collector mixin #1465

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
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

tpaschalis
Copy link
Member

@tpaschalis tpaschalis commented Jul 17, 2025

This PR introduces a new mixin for the OpenTelemetry collector that uses its internal Prometheus metrics.

It was constructed with grafonnet and tried to follow best practices. Let me know what you think!

@tpaschalis tpaschalis requested a review from a team as a code owner July 17, 2025 10:12
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
grafanaDashboards+:: {
'collector.json':
g.dashboard.new(
'OpenTelemetry Collector Health',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally use Sentence case for Dashboard titles and panel titles

)
+ prometheusQuery.withIntervalFactor(2)
+ prometheusQuery.withLegendFormat(|||
RSS - {{cluster}} - {{namespace}} - {{instance}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if otel collector is deployed outsude k8s and there is no namespace label?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take a look at the concept of three variables we use across all mixins:

  1. filteringSelector. Static label filter that must added to all queries in panels and alerts. This allows to deploy mixin more than once (with different filteringSlectors) or filter our unncessary metrics coming from other sources (otel-collectors you don't want to see on that dashboard). Could be empty. Example: job="integrations/otel-collector".

  2. groupLabels. a list of labels that represent a group of instances of SUO. Also labels you would like to keep in alerts aggregations. example: groupLabels: ['job'] or groupLabels: [environment, 'job', cluster`].

  3. instanceLabels. a list of labels that represent a single instance of SUO.
    example: instanceLabels: ['instance'] or instanceLabels: [instance`, 'pod'].

Moving those into config and then reusing those variables instead of static labels in queries, dashboard variables , panel legends gives maximum flexibility no matter where mixin is deployed.

Comment on lines +5 to +30
{
datasourceVariable:
variable.datasource.new('datasource', 'prometheus')
+ variable.datasource.generalOptions.withLabel('Data source')
+ variable.datasource.generalOptions.withCurrent(cfg._config.datasourceName)
+ variable.datasource.generalOptions.showOnDashboard.withLabelAndValue(),

clusterVariable:
variable.query.new('cluster')
+ variable.query.generalOptions.withLabel('Cluster')
+ variable.query.withDatasourceFromVariable(self.datasourceVariable)
+ variable.query.refresh.onTime()
+ variable.query.withSort(type='alphabetical', asc=false)
+ variable.query.selectionOptions.withIncludeAll(true, '.*')
+ variable.query.selectionOptions.withMulti(true)
+ variable.query.queryTypes.withLabelValues('cluster', metric='{__name__=~"otelcol_process_uptime.*"}'),

namespaceVariable:
variable.query.new('namespace')
+ variable.query.generalOptions.withLabel('Namespace')
+ variable.query.withDatasourceFromVariable(self.datasourceVariable)
+ variable.query.refresh.onTime()
+ variable.query.withSort(type='alphabetical', asc=false)
+ variable.query.selectionOptions.withIncludeAll(true, '.*')
+ variable.query.selectionOptions.withMulti(true)
+ variable.query.queryTypes.withLabelValues('namespace', metric='{__name__=~"otelcol_process_uptime.*"}'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +8 to +28
cpuUsage:
prometheusQuery.new(
'$' + variables.datasourceVariable.name,
|||
sum by (job, cluster, namespace, instance) (
rate(
{
__name__=~"otelcol_process_cpu_seconds(_total)?",
job=~"$job",
cluster=~"$cluster",
namespace=~"$namespace",
instance=~"$instance"
}
[$__rate_interval])
)
|||
)
+ prometheusQuery.withIntervalFactor(2)
+ prometheusQuery.withLegendFormat(|||
{{cluster}} - {{namespace}} - {{instance}}
|||),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants