Skip to content

Add StatsD transport protocol configuration option #22125

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.time.Duration;

import io.micrometer.statsd.StatsdFlavor;
import io.micrometer.statsd.StatsdProtocol;

import org.springframework.boot.context.properties.ConfigurationProperties;

Expand Down Expand Up @@ -53,6 +54,11 @@ public class StatsdProperties {
*/
private Integer port = 8125;

/**
* Protocol of the StatsD server to receive exported metrics.
*/
private StatsdProtocol protocol = StatsdProtocol.UDP;

/**
* Total length of a single payload should be kept within your network's MTU.
*/
Expand Down Expand Up @@ -102,6 +108,14 @@ public void setPort(Integer port) {
this.port = port;
}

public StatsdProtocol getProtocol() {
return this.protocol;
}

public void setProtocol(StatsdProtocol protocol) {
this.protocol = protocol;
}

public Integer getMaxPacketLength() {
return this.maxPacketLength;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import io.micrometer.statsd.StatsdConfig;
import io.micrometer.statsd.StatsdFlavor;
import io.micrometer.statsd.StatsdProtocol;

import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PropertiesConfigAdapter;

Expand Down Expand Up @@ -65,6 +66,11 @@ public int port() {
return get(StatsdProperties::getPort, StatsdConfig.super::port);
}

@Override
public StatsdProtocol protocol() {
return get(StatsdProperties::getProtocol, StatsdConfig.super::protocol);
}

@Override
public int maxPacketLength() {
return get(StatsdProperties::getMaxPacketLength, StatsdConfig.super::maxPacketLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@
"name": "management.metrics.export.statsd.flavor",
"defaultValue": "datadog"
},
{
"name": "management.metrics.export.statsd.protocol",
"defaultValue": "udp"
},
{
"name": "management.metrics.export.statsd.queue-size",
"defaultValue": 2147483647,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void defaultValuesAreConsistent() {
assertThat(properties.getFlavor()).isEqualTo(config.flavor());
assertThat(properties.getHost()).isEqualTo(config.host());
assertThat(properties.getPort()).isEqualTo(config.port());
assertThat(properties.getProtocol()).isEqualTo(config.protocol());
assertThat(properties.getMaxPacketLength()).isEqualTo(config.maxPacketLength());
assertThat(properties.getPollingFrequency()).isEqualTo(config.pollingFrequency());
assertThat(properties.isPublishUnchangedMeters()).isEqualTo(config.publishUnchangedMeters());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1764,12 +1764,13 @@ You can also change the interval at which metrics are sent to Stackdriver:
==== StatsD
The StatsD registry pushes metrics over UDP to a StatsD agent eagerly.
By default, metrics are exported to a {micrometer-registry-docs}/statsd[StatsD] agent running on your local machine.
The StatsD agent host and port to use can be provided using:
The StatsD agent host,port, and protocol to use can be provided using:
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be a space after host, i.e. .. host, port, ...


[source,properties,indent=0,configprops]
----
management.metrics.export.statsd.host=statsd.example.com
management.metrics.export.statsd.port=9125
management.metrics.export.statsd.protocol=udp
----

You can also change the StatsD line protocol to use (default to Datadog):
Expand Down