kamon-prometheus

kamon prometheus integration

Github 星跟踪图

Prometheus Integration kamon-logo.svg

Build Status Gitter Maven Central

Getting Started

Kamon Prometheus is currently available for Scala 2.10, 2.11 and 2.12.

Supported releases and dependencies are shown below., kamon, status, jdk, scala, :----------:, :------:, :----:, ------------------, 1.1.2, stable, 1.8+, 2.10, 2.11, 2.12

Adding the Reporter to your project

First, add the dependency to your build. For SBT that would look like this:

libraryDependencies += "io.kamon" %% "kamon-prometheus" % "1.1.2"

and for Maven:

<dependency>
    <groupId>io.kamon</groupId>
    <artifactId>kamon-prometheus_2.12</artifactId>
    <version>1.1.2</version>
</dependency>

Then, start the reporter when your application starts:

import kamon.prometheus.PrometheusReporter
Kamon.addReporter(new PrometheusReporter())

That's it! You can now go to `http://localhost:9095 and see the metrics. Check the reference.conf file for more details on what settings can be configured for the module.

Consuming the metrics

Finally, all you need to do is configure a scrape configuration in Prometheus. The following snippet is a minimal example that shold work with the minimal server from the previous section.


A minimal Prometheus configuration snippet
------------------------------------------------------------------------------
scrape_configs:
  - job_name: kamon-prometheus
    static_configs:
      - targets: ['localhost:9095']
------------------------------------------------------------------------------
Custom environment tags

Kamon allows you to provide custom environment tags to all your metrics by configuring kamon.environment.tags in your application.conf, e.g.

kamon.environment.tags {
  custom-id = "test1"
  env = staging
}

In order to include these tags in your Prometheus metrics as well, you need to activate this feature for the PrometheusReporter by setting

kamon.prometheus.include-environment-tags = yes

in your application.conf as well, yielding, for example

# TYPE some_metric_seconds_total counter
some_metric_seconds_total{custom_id="test1",env="staging"} 10.0
# TYPE some_metric_seconds gauge
some_metric_seconds{custom_id="test1",env="staging"} 10.0

Note that environment tags always have precedence over any other custom tag that may have been set by the application at runtime.

项目概况

主要编程语言Scala
编程语言Scala
许可证Other
最新版本名称v2.0.1
第一版名称v1.0.0-RC4
最后发布时间2019-12-20 15:26:34
首次发布2017-11-23 03:50:22
最后一次提交2020-03-31 11:57:07
创建于2017-06-18T21:39:18
推送于2020-03-31T09:57:14
提交数79
关注者数9
名称与所有者kamon-io/kamon-prometheus
派生数23
星数30
问题数13
发布数10
语言数1
拉请求数14
关闭的拉请求数5
已启用问题?
已启用Wiki?
已存档?
是分叉?
已锁定?
是镜像?
是私有?
To the top