prometheus-datadog-bridge


License

License

MIT
Categories

Categories

Data Prometheus Application Testing & Monitoring Monitoring
GroupId

GroupId

io.github.chris-zen
ArtifactId

ArtifactId

prometheus-datadog-bridge_2.11
Last Version

Last Version

0.1.6
Release Date

Release Date

Type

Type

jar
Description

Description

prometheus-datadog-bridge
prometheus-datadog-bridge
Project URL

Project URL

https://github.com/chris-zen/prometheus-datadog-bridge
Project Organization

Project Organization

io.github.chris-zen
Source Code Management

Source Code Management

https://github.com/chris-zen/prometheus-datadog-bridge

Download prometheus-datadog-bridge_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.chris-zen/prometheus-datadog-bridge_2.11/ -->
<dependency>
    <groupId>io.github.chris-zen</groupId>
    <artifactId>prometheus-datadog-bridge_2.11</artifactId>
    <version>0.1.6</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.chris-zen/prometheus-datadog-bridge_2.11/
implementation 'io.github.chris-zen:prometheus-datadog-bridge_2.11:0.1.6'
// https://jarcasting.com/artifacts/io.github.chris-zen/prometheus-datadog-bridge_2.11/
implementation ("io.github.chris-zen:prometheus-datadog-bridge_2.11:0.1.6")
'io.github.chris-zen:prometheus-datadog-bridge_2.11:jar:0.1.6'
<dependency org="io.github.chris-zen" name="prometheus-datadog-bridge_2.11" rev="0.1.6">
  <artifact name="prometheus-datadog-bridge_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.chris-zen', module='prometheus-datadog-bridge_2.11', version='0.1.6')
)
libraryDependencies += "io.github.chris-zen" % "prometheus-datadog-bridge_2.11" % "0.1.6"
[io.github.chris-zen/prometheus-datadog-bridge_2.11 "0.1.6"]

Dependencies

compile (4)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
org.slf4j : slf4j-api jar 1.7.25
io.prometheus : simpleclient jar 0.6.0
com.datadoghq : java-dogstatsd-client jar 2.7

test (3)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 jar 1.7.25
org.scalatest : scalatest_2.11 jar 3.0.4
org.mockito : mockito-core jar 3.3.3

Project Modules

There are no modules declared in this project.

prometheus-datadog-bridge

Build Coverage Download

A Prometheus bridge to push metrics into Datadog

Examples of use

There are two cases where the Prometheus bridge to Datadog can be used.

Services

A service can be seen as an application that it is running all the time and needs to report metrics periodically. The following example shows how easy is to setup the bridge to report at intervals of 30 seconds.

import java.time.Duration
import io.prometheus.client.Summary
import com.github.chris_zen.prometheus.bridge.datadog.{DatadogBridge, DatadogBridgeConfig}

object ServiceExample {

  private val execTime = Summary.build("exec_time_ms", "Execution time").register()
  
  private val ReportingSeconds = 30

  def main(args: Array[String]): Unit = {
    
    val bridgeConfig = DatadogBridgeConfig()
      .withPrefix("example")
      .withTags("name:example", "team:mazingerz")
      .withPeriod(Duration.ofSeconds(ReportingSeconds))
    
    val bridge = DatadogBridge(bridgeConfig)
    
    while (true) {
      instrumentedCode()
    }
    
    bridge.stop()
  }

  private def instrumentedCode(): Unit = {
    val timer = execTime.startTimer()

    // Do something ...

    timer.observeDuration()
  }
}

Batch jobs

A batch job is an application that executes for an specific period of time and then finishes. In such cases, rather than being interested in reporting metrics periodically, it is more interesting to report the metrics at the end, when the logic has finished and the metrics have been computed.

import com.github.chris_zen.prometheus.bridge.datadog.{DatadogBridgeConfig, DatadogPush}
import io.prometheus.client.Summary

object BatchJobExample {

  private val execTime = Summary.build("exec_time_ms", "Execution time").register()

  def main(args: Array[String]): Unit = {

    instrumentedCode()

    val bridgeConfig = DatadogBridgeConfig()
      .withPrefix("example")
      .withTags("name:example", "team:mazingerz")

    DatadogPush(bridgeConfig)
      .push()
      .close()
  }

  private def instrumentedCode(): Unit = {
    val timer = execTime.startTimer()

    // Do something ...

    timer.observeDuration()
  }
}

Versions

Version
0.1.6
0.1.5+10-138fe185
0.1.5+1-5d2e2d78