Skip to content

Commit 593f34f

Browse files
committed
feat: opentelemetry-collector-observ-lib
1 parent dedb779 commit 593f34f

File tree

21 files changed

+3876
-0
lines changed

21 files changed

+3876
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
exclusions:
2+
target-instance-rule:
3+
reason: "The job label is used differently in the otel world (`service.name` maps to `job` and is the same across instances)"
4+
template-instance-rule:
5+
reason: "The job label is used differently in the otel world (`service.name` maps to `job` and is the same across instances)"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../Makefile_mixin
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# OpenTelemetry Collector observability library
2+
3+
This library can be used to generate dashboards, rows, panels, and alerts for [OpenTelemetry Collector internal telemetry](https://opentelemetry.io/docs/collector/internal-telemetry/) .
4+
5+
Supports the following sources:
6+
7+
## Import
8+
9+
```sh
10+
jb init
11+
jb install https://github.com/grafana/jsonnet-libs/opentelemetry-collector-observ-lib
12+
```
13+
14+
## Example: Generate monitoring-mixin
15+
16+
```.jsonnet
17+
local otelcollib = import 'opentelemetry-collector-observ-lib/main.libsonnet';
18+
local otelcol =
19+
otelcollib.new()
20+
+ otelcollib.withConfigMixin(
21+
{
22+
filteringSelector: 'job!=""',
23+
}
24+
);
25+
otelcollib.asMonitoringMixin()
26+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
local common = import './signals/common.libsonnet';
2+
3+
{
4+
new(this): {
5+
6+
groups: [
7+
{
8+
name: this.config.uid + '-rules',
9+
rules:
10+
[
11+
{
12+
alert: 'ExporterQueueSaturated',
13+
expr: 'sum(otelcol_exporter_queue_size{}) by (data_type,service_instance_id,exporter) / sum(otelcol_exporter_queue_capacity{}) by (data_type,service_instance_id,exporter) > 0.8',
14+
'for': '5m',
15+
keep_firing_for: '5m',
16+
labels: {
17+
service_name: 'opentelemetry-collector',
18+
severity: 'warning',
19+
},
20+
annotations: {
21+
summary: 'Exporter queue is reaching limit.',
22+
description: 'The {{ $labels.data_type }} queue of the {{ $labels.exporter }} exporter is almost full ({{ $value }}). It will start dropping data once full',
23+
},
24+
},
25+
]
26+
+ [
27+
{
28+
alert: '%(capitalized)sFailedToSend' % signal,
29+
expr: 'sum(rate(otelcol_exporter_enqueue_failed_%(metric_id)s_total{}[5m])) by (exporter,service_instance_id) > 0' % signal,
30+
'for': '5m',
31+
keep_firing_for: '5m',
32+
labels: {
33+
service_name: 'opentelemetry-collector',
34+
severity: 'critical',
35+
},
36+
annotations: {
37+
summary: 'Failed to enqueue %(plural)s for export.' % signal,
38+
description: 'Collector {{ $labels.service_instance_id }} failed to enqueue %(plural)s for the {{ $labels.exporter }}' % signal,
39+
},
40+
}
41+
for signal in common.signalTypes
42+
],
43+
},
44+
],
45+
},
46+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
local this = self,
3+
filteringSelector: 'job!=""',
4+
groupLabels: [],
5+
instanceLabels: ['job', 'service_instance_id'],
6+
uid: 'otelcol',
7+
dashboardNamePrefix: '',
8+
dashboardTags: ['opentelemetry', 'collector'],
9+
metricsSource: 'otelcol',
10+
signals+:
11+
{
12+
receiver: (import './signals/receiver.libsonnet')(this),
13+
processor: (import './signals/processor.libsonnet')(this),
14+
exporter: (import './signals/exporter.libsonnet')(this),
15+
},
16+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
local g = import './g.libsonnet';
2+
{
3+
local root = self,
4+
new(this):
5+
{
6+
'otelcol-overview.json':
7+
g.dashboard.new(this.config.dashboardNamePrefix + 'Collector overview')
8+
+ g.dashboard.withVariables(this.signals.receiver.getVariablesMultiChoice())
9+
+ g.dashboard.withVariablesMixin([
10+
{
11+
datasource: {
12+
type: 'prometheus',
13+
uid: '${datasource}',
14+
},
15+
baseFilters: [],
16+
filters: [],
17+
label: 'Extra filters',
18+
name: 'adhoc',
19+
type: 'adhoc',
20+
},
21+
])
22+
+ g.dashboard.withTags(this.config.dashboardTags)
23+
+ g.dashboard.withUid(this.config.uid + '-overview-dashboard')
24+
+ g.dashboard.withPanels(
25+
g.util.panel.resolveCollapsedFlagOnRows(
26+
g.util.grid.wrapPanels(
27+
[
28+
this.grafana.rows.overview,
29+
this.grafana.rows.process,
30+
this.grafana.rows.receivers,
31+
this.grafana.rows.processors,
32+
this.grafana.rows.exporters,
33+
]
34+
)
35+
),
36+
setPanelIDs=false
37+
),
38+
},
39+
}

0 commit comments

Comments
 (0)