Slackbot
01/10/2024, 5:55 PMMike Sherman
01/10/2024, 6:15 PMCustomize the Metric Emitter:
Druid supports customizing the metric emitter. You can implement your custom metric emitter class by extending the appropriate Druid metric emitter class.
Include Cluster Name as Metadata:
Within your custom metric emitter, you can include additional metadata, such as the Druid cluster name, with each emitted metric. This metadata can be added to the emitted metric data.
Register the Custom Emitter:
Register your custom metric emitter in the Druid configuration. This involves specifying the fully qualified class name of your custom emitter in the Druid configuration.
Implement Custom HTTP Service:
On the receiving end (your HTTP endpoint service), modify the service to parse the incoming metrics and extract the additional metadata (e.g., Druid cluster name) for further processing.Mike Sherman
01/10/2024, 6:18 PMMike Sherman
01/10/2024, 6:18 PMimport org.apache.druid.emitter.core.Emitter;
import org.apache.druid.emitter.http.HttpEmitterConfig;
public class CustomHttpEmitter extends HttpEmitter
{
private final String clusterName;
public CustomHttpEmitter(String clusterName, HttpEmitterConfig config)
{
super(config);
this.clusterName = clusterName;
}
@Override
protected String getFeed()
{
// Include the cluster name as part of the feed
return "druid/" + clusterName + "/metrics";
}
}
// Register the custom emitter in your Druid configurationSuneet Saldanha
01/11/2024, 2:59 PMExtraServiceDimensions. The service emitter will then report these dimensions along all metrics reported by DruidSuneet Saldanha
01/11/2024, 3:13 PMdruid.emitter.tags.clusterName=<myCluster>
druid.emitter.tags.clusterType=dev|prod
druid.emitter.tags.<tagName>=<tagValue>
The extension would then simply extract the key value pairs from any config that starts with druid.emitter.tags and bind it to the ExtraServiceDimensions
This should work if you wanted to distinguish which clusters the metrics that are being emitted belong to.Mike Sherman
01/11/2024, 3:30 PMSuneet Saldanha
01/11/2024, 4:05 PMMike Sherman
01/11/2024, 4:20 PMManaging library collisions can be daunting for extensions which draw in commonly used libraries