Skip to content

Commit 3a59894

Browse files
authored
Add support of fluentd metrics export (#10)
1 parent 8ceedda commit 3a59894

File tree

16 files changed

+1005
-36
lines changed

16 files changed

+1005
-36
lines changed

Gemfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ source "https://rubygems.org"
55
# Specify your gem's dependencies in fluent-plugin-opentelemetry.gemspec
66
gemspec
77

8-
gem "grpc", "~> 1.73"
8+
gem "grpc"
99
gem "grpc-tools"
1010
gem "irb"
11-
gem "rake", "~> 13.0"
12-
gem "test-unit", "~> 3.0"
11+
gem "rake"
12+
gem "rr"
13+
gem "test-unit"
14+
gem "test-unit-rr"
1315
gem "timecop"
1416

1517
gem "rubocop", "~> 1.75"

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $ bundle
2424

2525
## Configuration
2626

27-
### Input plugin
27+
### Input `opentelemetry` plugin
2828

2929
To receive data, this plugin requires `<http>` or `<grpc>` section, or both.
3030

@@ -106,7 +106,40 @@ Refer [Config: Transport Section](https://docs.fluentd.org/configuration/transpo
106106
</source>
107107
```
108108

109-
### Output plugin
109+
### Input `opentelemetry_metrics` plugin
110+
111+
This plugin emits Fluentd's metric data that conforms to the OpenTelemetry Protocol.
112+
To output the data, it requires to use output `opentelemetry` plugin.
113+
114+
#### Root section
115+
116+
| parameter | type | description | default |
117+
|--------------------|--------|-------------------------------------------------------|-------------|
118+
| tag | string | The tag of the event | required |
119+
| emit_interval | time | Determine the rate to emit internal metrics as events | `60` |
120+
| metric_name_prefix | string | The prefix of metric name | `fluentd_` |
121+
122+
#### Example
123+
124+
```
125+
# Emit Fluentd metrics
126+
<source>
127+
@type opentelemetry_metrics
128+
tag opentelemetry.fluentd.metrics
129+
emit_interval 300s
130+
</source>
131+
132+
# Send Fluentd metrics to OpenTelemetry Collector
133+
<match opentelemetry.fluentd.metrics>
134+
@type opentelemetry
135+
136+
<http>
137+
endpoint "https://127.0.0.1:4318"
138+
</http>
139+
</match>
140+
```
141+
142+
### Output `opentelemetry` plugin
110143

111144
To send data, this plugin requires `<http>` or `<grpc>` section.
112145

example/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ The telemetry data have been provided by js application in `app` directory.
1212

1313
```mermaid
1414
flowchart LR
15-
A[app/metrics.js] -->|metric data / otlp| C[Fluentd]
16-
B[app/tracing.js] -->|trace data / otlp| C[Fluentd]
17-
C[Fluentd] -->|metric data / otlp| D[Otel Collector]
18-
C[Fluentd] -->|trace data / otlp| F[Jaeger]
15+
A[app/metrics.js] -->|app metric data / otlp| C[Fluentd]
16+
B[app/tracing.js] -->|app trace data / otlp| C[Fluentd]
17+
C[Fluentd] -->|app metric data / otlp <br> Fluentd metric data / otlp| D[Otel Collector]
18+
C[Fluentd] -->|app trace data / otlp| F[Jaeger]
1919
C[Fluentd] -->|sample log / Fluentd Forward Protocol| D[Otel Collector]
20-
D[Otel Collector] -->|metric data| E[Prometheus / Grafana]
20+
D[Otel Collector] -->|app metric data <br> Fluentd metric data | E[Prometheus / Grafana]
2121
D[Otel Collector] -->|sample log| G[Elasticsearch / Kibana]
2222
```
2323

@@ -31,7 +31,7 @@ This demo uses Prometheus / Grafana to visualize the metrics data.
3131

3232
1. Go to [`localhost:3000`](http://localhost:3000) and login to Grafana using credentials admin, admin
3333

34-
2. Then, show `demo > Basic Service Trace` in [dashboard](http://localhost:3000/dashboards).
34+
2. Then, show `demo > OpenTelemetry` in [dashboard](http://localhost:3000/dashboards).
3535

3636
![dashboard](./assets/dashboard.png)
3737

@@ -54,7 +54,7 @@ This demo uses Elasticsearch / Kibana to visualize the trace data.
5454

5555
![discover](./assets/discover.png)
5656

57-
2. Specify `logs-*` to Index pattern and click Save data view to Kibana.
57+
2. Specify `logs-*` to Index pattern and click Save data view to Kibana.
5858

5959
![create data view](./assets/create_data_view.png)
6060

example/assets/dashboard.png

146 KB
Loading

example/fluentd/fluent.conf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
</http>
1515
</source>
1616

17+
<source>
18+
@type opentelemetry_metrics
19+
tag opentelemetry.fluentd.metrics
20+
emit_interval 15s
21+
</source>
22+
1723
# Send traces data to jaeger directly using OpenTelemetry Protocol
1824
<match opentelemetry.traces>
1925
@type opentelemetry
@@ -71,4 +77,4 @@
7177
port 24224
7278
weight 60
7379
</server>
74-
</match>
80+
</match>

example/grafana/dashboard-files/Basic_Services_Traces.json renamed to example/grafana/dashboard-files/OpenTelemetry.json

Lines changed: 103 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"editable": true,
2525
"fiscalYearStartMonth": 0,
2626
"graphTooltip": 0,
27-
"id": 2,
27+
"id": 3,
2828
"links": [],
2929
"panels": [
3030
{
@@ -61,6 +61,7 @@
6161
"type": "linear"
6262
},
6363
"showPoints": "auto",
64+
"showValues": false,
6465
"spanNulls": false,
6566
"stacking": {
6667
"group": "A",
@@ -76,7 +77,7 @@
7677
"steps": [
7778
{
7879
"color": "green",
79-
"value": null
80+
"value": 0
8081
},
8182
{
8283
"color": "red",
@@ -107,7 +108,7 @@
107108
"sort": "none"
108109
}
109110
},
110-
"pluginVersion": "11.5.2",
111+
"pluginVersion": "12.2.0",
111112
"targets": [
112113
{
113114
"datasource": {
@@ -126,13 +127,107 @@
126127
"useBackend": false
127128
}
128129
],
129-
"title": "Basic Service",
130+
"title": "Application metrics",
131+
"type": "timeseries"
132+
},
133+
{
134+
"datasource": {
135+
"type": "prometheus",
136+
"uid": "PBFA97CFB590B2093"
137+
},
138+
"fieldConfig": {
139+
"defaults": {
140+
"color": {
141+
"mode": "palette-classic"
142+
},
143+
"custom": {
144+
"axisBorderShow": false,
145+
"axisCenteredZero": false,
146+
"axisColorMode": "text",
147+
"axisLabel": "",
148+
"axisPlacement": "auto",
149+
"barAlignment": 0,
150+
"barWidthFactor": 0.6,
151+
"drawStyle": "line",
152+
"fillOpacity": 0,
153+
"gradientMode": "none",
154+
"hideFrom": {
155+
"legend": false,
156+
"tooltip": false,
157+
"viz": false
158+
},
159+
"insertNulls": false,
160+
"lineInterpolation": "linear",
161+
"lineWidth": 1,
162+
"pointSize": 5,
163+
"scaleDistribution": {
164+
"type": "linear"
165+
},
166+
"showPoints": "auto",
167+
"showValues": false,
168+
"spanNulls": false,
169+
"stacking": {
170+
"group": "A",
171+
"mode": "none"
172+
},
173+
"thresholdsStyle": {
174+
"mode": "off"
175+
}
176+
},
177+
"mappings": [],
178+
"thresholds": {
179+
"mode": "absolute",
180+
"steps": [
181+
{
182+
"color": "green",
183+
"value": 0
184+
},
185+
{
186+
"color": "red",
187+
"value": 80
188+
}
189+
]
190+
}
191+
},
192+
"overrides": []
193+
},
194+
"gridPos": {
195+
"h": 8,
196+
"w": 12,
197+
"x": 0,
198+
"y": 9
199+
},
200+
"id": 3,
201+
"options": {
202+
"legend": {
203+
"calcs": [],
204+
"displayMode": "list",
205+
"placement": "bottom",
206+
"showLegend": true
207+
},
208+
"tooltip": {
209+
"hideZeros": false,
210+
"mode": "single",
211+
"sort": "none"
212+
}
213+
},
214+
"pluginVersion": "12.2.0",
215+
"targets": [
216+
{
217+
"editorMode": "code",
218+
"expr": "{__name__=~\"^fluentd_.*\"}",
219+
"legendFormat": "__auto",
220+
"range": true,
221+
"refId": "A"
222+
}
223+
],
224+
"title": "Fluentd metrics",
130225
"type": "timeseries"
131226
}
132227
],
133228
"preload": false,
134229
"refresh": "5s",
135-
"schemaVersion": 40,
230+
"schemaVersion": 42,
136231
"tags": [],
137232
"templating": {
138233
"list": []
@@ -143,8 +238,7 @@
143238
},
144239
"timepicker": {},
145240
"timezone": "",
146-
"title": "Basic Service Traces",
241+
"title": "OpenTelemetry",
147242
"uid": "y36s8FHVz",
148-
"version": 1,
149-
"weekStart": ""
150-
}
243+
"version": 2
244+
}

example/prometheus/prometheus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
global:
2-
scrape_interval: 15s
2+
scrape_interval: 15s
33
evaluation_interval: 15s
44

55
scrape_configs:

fluent-plugin-opentelemetry.gemspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# frozen_string_literal: true
22

3+
require_relative "lib/fluent/plugin/opentelemetry/version"
4+
35
Gem::Specification.new do |spec|
46
spec.name = "fluent-plugin-opentelemetry"
5-
spec.version = "0.3.0"
7+
spec.version = Fluent::Plugin::Opentelemetry::VERSION
68
spec.authors = ["Shizuo Fujita"]
79
spec.email = ["[email protected]"]
810

gemfiles/grpc.gemfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ source "https://rubygems.org"
44

55
gemspec path: "../"
66

7-
gem "grpc", "~> 1.73"
8-
gem "rake", "~> 13.0"
9-
gem "test-unit", "~> 3.0"
7+
gem "grpc"
8+
gem "rake"
9+
gem "rr"
10+
gem "test-unit"
11+
gem "test-unit-rr"
1012
gem "timecop"

gemfiles/http.gemfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ source "https://rubygems.org"
44

55
gemspec path: "../"
66

7-
# gem "grpc", "~> 1.73"
8-
gem "rake", "~> 13.0"
9-
gem "test-unit", "~> 3.0"
7+
# gem "grpc"
8+
gem "rake"
9+
gem "rr"
10+
gem "test-unit"
11+
gem "test-unit-rr"
1012
gem "timecop"

0 commit comments

Comments
 (0)