Skip to content

Commit 5f7ee6a

Browse files
[statsd_input] Make StatsD input package GA (#15125)
Co-authored-by: Arianna Laudazzi <[email protected]> Co-authored-by: Arianna Laudazzi <[email protected]>
1 parent 823273b commit 5f7ee6a

File tree

7 files changed

+208
-14
lines changed

7 files changed

+208
-14
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dependencies:
22
ecs:
3-
reference: "git@v8.11.0"
3+
reference: "git@v8.17.0"

packages/statsd_input/_dev/deploy/docker/docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: '2.3'
21
services:
32
statsd_input:
43
image: docker.elastic.co/observability/stream:v0.18.0

packages/statsd_input/agent/input/input.yml.hbs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ metricsets: ["server"]
22
host: {{listen_address}}
33
port: {{listen_port}}
44
data_stream:
5-
dataset: {{data_stream.dataset}}
5+
dataset: {{data_stream.dataset}}
6+
ttl: {{ttl}}
7+
{{#if statsd.mappings}}
8+
statsd.mappings: {{statsd.mappings}}
9+
{{/if}}

packages/statsd_input/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "1.0.0"
3+
changes:
4+
- description: Make StatsD input package GA.
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/15125
27
- version: "0.6.0"
38
changes:
49
- description: Update format_version to 3.4.0.
Lines changed: 169 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,184 @@
11
# StatsD input
22

3+
## Overview
4+
35
The `statsd input package` spawns a UDP server and listens for metrics in StatsD compatible format.
46
This input can be used to collect metrics from services that send data over the StatsD protocol. To tailor the data you can provide custom mappings and ingest pipelines through Kibana.
57

6-
## Metric types
8+
### Compatibility
9+
10+
#### Metric types
711

812
The input supports the following types of metrics:
913

10-
**Counter (c)**:: Measurement which accumulates over a period of time until flushed (value set to 0).
14+
**Counter (c)**
15+
: Measurement which accumulates over period of time until flushed (value set to 0).
16+
17+
**Gauge (g)**
18+
: Measurement which can increase, decrease or be set to a value.
19+
20+
**Timer (ms)**
21+
: Time measurement (in milliseconds) of an event.
22+
23+
**Histogram (h)**
24+
: Time measurement, alias for timer.
25+
26+
**Set (s)**
27+
: Measurement which counts unique occurrences until flushed (value set to 0).
28+
29+
#### Supported tag extensions
30+
31+
Example of tag styles supported by the `statsd` input:
32+
33+
[DogStatsD](https://docs.datadoghq.com/developers/dogstatsd/datagram_shell/?tab=metrics#the-dogstatsd-protocol)
34+
35+
`<metric name>:<value>|<type>|@samplerate|#<k>:<v>,<k>:<v>`
36+
37+
[InfluxDB](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/statsd/README.md#influx-statsd)
38+
39+
`<metric name>,<k>=<v>,<k>=<v>:<value>|<type>|@samplerate`
40+
41+
[Graphite_1.1.x](https://graphite.readthedocs.io/en/latest/tags.html#graphite-tag-support)
42+
43+
`<metric name>;<k>=<v>;<k>=<v>:<value>|<type>|@samplerate`
44+
45+
## What data does this integration collect?
46+
47+
The StatsD input integration collects one type of data streams: metrics.
48+
49+
## What do I need to use this integration?
50+
51+
You need Elasticsearch for storing and searching your data and Kibana for visualizing and managing it.
52+
You can use our hosted Elasticsearch Service on Elastic Cloud, which is recommended, or self-manage the Elastic Stack on your own hardware.
53+
54+
## How do I deploy this integration?
55+
56+
For step-by-step instructions on how to set up an integration, check the
57+
[Getting started](https://www.elastic.co/guide/en/welcome-to-elastic/current/getting-started-observability.html) guide.
58+
59+
### Configuration options
60+
61+
The `statsd` input has these additional configuration options:
62+
63+
**Listen Address and Listen Port**
64+
: Bind address and port for the UDP server to listen on.
65+
66+
**TTL**
67+
: It defines how long a metric will be reported after it was last recorded. Metrics are always reported at least once, regardless of the specified TTL. A TTL of zero indicates that the metrics never expire.
68+
69+
**StatsD metric mappings (Optional)**
70+
: It defines how metrics will be mapped from the original metric label to the event JSON. Here’s an example configuration:
71+
72+
```yaml
73+
- metric: 'ti_failures' <1>
74+
value:
75+
field: task_failures <2>
76+
- metric: '<job_name>_start' <1>
77+
labels:
78+
- attr: job_name <3>
79+
field: job_name <4>
80+
value:
81+
field: started <2>
82+
```
83+
84+
1. `metric`, required: The label key of the metric in statsd, either as an exact match string, or as a template with named label placeholder in the format `<label_placeholder>`.
85+
2. `value.field`, required: Field name where to save the metric value in the event JSON.
86+
3. `label[].attr`, required when using the label placeholder: Reference to the label placeholder defined in `metric`.
87+
4. `label[].field`, required when using the label placeholder field name where to save the label placeholder value from the template in the event JSON.
88+
89+
**Important**:
90+
- If the `statsd.mappings` is provided, only the metrics mentioned in it will remain.
91+
- If the `statsd.mappings` is provided, then flattening (replacing dots `.` with underscores `_` in metric names) is not applied.
92+
- If the `statsd.mappings` is NOT provided (default), then flattening is applied, e.g. `python.gauge.foo:10|g` becomes `python_gauge_foo:10|g`.
93+
94+
## Troubleshooting
95+
96+
General troubleshooting checklist (detailed steps depend on the environment):
97+
- Make sure Elastic Agent is running.
98+
- Check that the Elastic Agent is listening on the specified UDP port.
99+
- Inspect network connectivity and check firewall rules.
100+
- Examine Elastic Agent logs.
101+
- Make sure that the application or service sending metrics is correctly configured to point to the right UDP endpoint.
102+
103+
If the `nc` is available in the environment, a sample UDP packet with StatsD payload may be sent using `nc` to check if the configuration is correct and the document appears in Kibana:
11104

12-
**Gauge (g)**:: Measurement which can increase, decrease or be set to a value.
105+
```bash
106+
# Replace "localhost" and "8125" with your values
107+
echo "sample:1|g" | nc -u -w0 localhost 8125
108+
```
13109

14-
**Timer (ms)**:: Time measurement (in milliseconds) of an event.
110+
## Metrics reference
15111

16-
**Histogram (h)**:: Time measurement, an alias for the *Timer*.
112+
### Example document
17113

18-
**Set (s)**:: Measurement which counts unique occurrences until flushed (value set to 0).
114+
Provided that the elastic-agent with StatsD input integration is listening on `localhost:8125`, it is possible to send a UDP packet with the following bash one-liner:
19115

116+
`echo "python_gauge_foo:10|g" | nc -u -w0 localhost 8125`
20117

21-
## Compatibility
118+
The resulting event will look like this:
22119

23-
Node.js version v18.12.1 is used to test the Statsd input package
120+
```json
121+
{
122+
"@timestamp": "2024-06-19T06:26:36.664Z",
123+
"agent": {
124+
"ephemeral_id": "f9a3bc3e-14ed-4245-a140-38032ec3e459",
125+
"id": "b138c66d-6261-4eac-a652-7f30ea89bcfc",
126+
"name": "docker-fleet-agent",
127+
"type": "metricbeat",
128+
"version": "8.13.0"
129+
},
130+
"data_stream": {
131+
"dataset": "statsd_input.statsd",
132+
"namespace": "ep",
133+
"type": "metrics"
134+
},
135+
"ecs": {
136+
"version": "8.17.0"
137+
},
138+
"elastic_agent": {
139+
"id": "b138c66d-6261-4eac-a652-7f30ea89bcfc",
140+
"snapshot": false,
141+
"version": "8.13.0"
142+
},
143+
"event": {
144+
"agent_id_status": "verified",
145+
"dataset": "statsd_input.statsd",
146+
"ingested": "2024-06-19T06:26:46Z",
147+
"module": "statsd"
148+
},
149+
"host": {
150+
"architecture": "x86_64",
151+
"containerized": true,
152+
"hostname": "docker-fleet-agent",
153+
"id": "8259e024976a406e8a54cdbffeb84fec",
154+
"ip": [
155+
"192.168.253.7"
156+
],
157+
"mac": [
158+
"02-42-C0-A8-FD-07"
159+
],
160+
"name": "docker-fleet-agent",
161+
"os": {
162+
"codename": "focal",
163+
"family": "debian",
164+
"kernel": "3.10.0-1160.102.1.el7.x86_64",
165+
"name": "Ubuntu",
166+
"platform": "ubuntu",
167+
"type": "linux",
168+
"version": "20.04.6 LTS (Focal Fossa)"
169+
}
170+
},
171+
"labels": {},
172+
"metricset": {
173+
"name": "server"
174+
},
175+
"service": {
176+
"type": "statsd"
177+
},
178+
"statsd": {
179+
"python_gauge_foo": {
180+
"value": 10
181+
}
182+
}
183+
}
184+
```

packages/statsd_input/manifest.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
format_version: 3.4.0
1+
format_version: 3.0.4
22
name: statsd_input
33
title: StatsD Input
4-
version: "0.6.0"
4+
version: "1.0.0"
55
description: StatsD Input Package
66
type: input
77
categories:
@@ -41,6 +41,31 @@ policy_templates:
4141
required: true
4242
show_user: true
4343
default: 8125
44+
- name: ttl
45+
type: text
46+
title: TTL
47+
description: |
48+
It defines how long a metric will be reported after it was last recorded. Irrespective of the given ttl, metrics will be reported at least once. A ttl of zero means metrics will never expire.
49+
required: true
50+
show_user: false
51+
default: 30s
52+
- name: statsd.mappings
53+
type: yaml
54+
title: StatsD metric mappings
55+
description: |
56+
It defines how metrics will mapped from the original metric label to the event json.
57+
required: false
58+
show_user: false
59+
default: |
60+
# - metric: 'ti_failures'
61+
# value:
62+
# field: task_failures
63+
# - metric: '<job_name>_start'
64+
# labels:
65+
# - attr: job_name
66+
# field: job_name
67+
# value:
68+
# field: started
4469
owner:
4570
github: elastic/obs-infraobs-integrations
4671
type: elastic

packages/statsd_input/sample_event.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"type": "metrics"
1414
},
1515
"ecs": {
16-
"version": "8.0.0"
16+
"version": "8.17.0"
1717
},
1818
"elastic_agent": {
1919
"id": "b138c66d-6261-4eac-a652-7f30ea89bcfc",

0 commit comments

Comments
 (0)