metrics-csv-table-reporter


License

License

MIT
Categories

Categories

CSV Data Data Formats Metrics Application Testing & Monitoring Monitoring
GroupId

GroupId

com.github.gchudnov
ArtifactId

ArtifactId

metrics-csv-table-reporter_2.13
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

metrics-csv-table-reporter
metrics-csv-table-reporter
Project URL

Project URL

https://github.com/gchudnov/metrics-csv-table-reporter
Project Organization

Project Organization

com.github.gchudnov
Source Code Management

Source Code Management

https://github.com/gchudnov/metrics-csv-table-reporter

Download metrics-csv-table-reporter_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.gchudnov/metrics-csv-table-reporter_2.13/ -->
<dependency>
    <groupId>com.github.gchudnov</groupId>
    <artifactId>metrics-csv-table-reporter_2.13</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.gchudnov/metrics-csv-table-reporter_2.13/
implementation 'com.github.gchudnov:metrics-csv-table-reporter_2.13:1.0.1'
// https://jarcasting.com/artifacts/com.github.gchudnov/metrics-csv-table-reporter_2.13/
implementation ("com.github.gchudnov:metrics-csv-table-reporter_2.13:1.0.1")
'com.github.gchudnov:metrics-csv-table-reporter_2.13:jar:1.0.1'
<dependency org="com.github.gchudnov" name="metrics-csv-table-reporter_2.13" rev="1.0.1">
  <artifact name="metrics-csv-table-reporter_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.gchudnov', module='metrics-csv-table-reporter_2.13', version='1.0.1')
)
libraryDependencies += "com.github.gchudnov" % "metrics-csv-table-reporter_2.13" % "1.0.1"
[com.github.gchudnov/metrics-csv-table-reporter_2.13 "1.0.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.1
io.dropwizard.metrics : metrics-core jar 4.1.1

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.13 jar 3.0.8

Project Modules

There are no modules declared in this project.

metrics-csv-table-reporter

Capture metrics to a single csv table.


Usage

Add the following dependency to your build.sbt:

libraryDependencies += "com.github.gchudnov" %% "metrics-csv-table-reporter" % "1.0.1"

Optionally, add github credentials and package repository resolver to build.sbt:

credentials += Credentials(Path.userHome / ".sbt" / ".credentials")
resolvers += Resolver.url("GitHub Package Registry", url("https://maven.pkg.github.com/gchudnov/metrics-csv-table-reporter"))

// cat ~/.sbt/.credentials
// realm=GitHub Package Registry
// host=maven.pkg.github.com
// user=USER
// password=TOKEN

In your code, import com.github.gchudnov.metrics.CsvTableReporter, construct and start the reporter:

import java.io.FileOutputStream
import com.codahale.metrics.MetricRegistry
import com.github.gchudnov.metrics.CsvTableReporter

val registry = new MetricRegistry
val outStream = new FileOutputStream("/some/path/report.csv", true)

val reporter = CsvTableReporter
  .forRegistry(registry)
  .outputTo(out)
  .build()

reporter.writeHeader()
reporter.start(1.second.toSeconds, TimeUnit.SECONDS)

add meters, histograms to the registry. When running, metrics output will be appended to the provided output stream.

Quick Reference

CsvTableReporter
  .forRegistry(registry: MetricRegistry)                              // A registry to build a reporter for.
  .shutdownExecutorOnStop(shutdownExecutorOnStop: Boolean)            // Whether reporting executor stopped at the same time as reporter.
  .scheduleOn(executor: ScheduledExecutorService)                     // The executor to use while scheduling reporting of metrics.
  .outputTo(output: OutputStream = System.out)                        // Write to the given OutputStream.
  .withSeparator(separator: String = ";")                             // Delimiter to separate the values.
  .formattedFor(locale: Locale = Locale.getDefault())                 // Format numbers using the given Locale.
  .withClock(clock: Clock = Clock.defaultClock())                     // Clock to use to get the time.
  .formattedFor(timeZone: TimeZone = TimeZone.getDefault)             // Format time using the given TimeZone.
  .convertRatesTo(rateUnit: TimeUnit = TimeUnit.SECONDS)              // Convert rates to the given time unit.
  .convertDurationsTo(durationUnit: TimeUnit = TimeUnit.MILLISECONDS) // Convert durations to the given time unit.
  .filter(filter: MetricFilter = MetricFilter.ALL)                    // Report only metrics that match the given filter.
  .enabledColumns(Set[Column] = Columns.All)                          // Enable only specified columns in the output.

Output Fields

The output contains the following columns:

  • name - name of the metric.
  • kind - type of the metric. one of the: gauge, counter, histogram, meter, timer.
  • ts - timestamp.
  • value - measured value at the given time. Used by gauge.
  • count - number of events which have been marked. Used by counter, histogram, meter or timer.
  • max - max value.
  • mean - average value.
  • min - min value.
  • stddev - standard deviation -- how measurements are spread out from the average (mean) value.
  • p50 - median.
  • p75 - 75th percentile.
  • p95 - 95th percentile.
  • p98 - 98th percentile.
  • p99 - 99th percentile.
  • p999 - 99.9th percentile.
  • m1_rate - 1-minute exponentially-weighted moving average rate, converted to [1/rate_unit].
  • m5_rate - 5-minute exponentially-weighted moving average rate, converted to [1/rate_unit].
  • m15_rate - 15-minute exponentially-weighted moving average rate, converted to [1/rate_unit].
  • mean_rate - mean rate, converted to [1/rate_unit].
  • rate_unit - time unit used to measure the rate, e.g. second.
  • duration_unit - time unit used to measure the duration, e.g. milliseconds.

Rates m1_rate, m5_rate, m15_rate, mean_rate define the throughput; - how many units (events) where processed per rate_unit.

Metric-related columns

| kind      | value | count | max | mean | min | stddev | p50 | p75 | p95 | p98 | p99 | p999 | m1_rate | m5_rate | m15_rate | mean_rate |
| --------- | ----- | ----- | --- | ---- | --- | ------ | --- | --- | --- | --- | --- | ---- | ------- | ------- | -------- | --------- |
| gauge     | x     |       |     |      |     |        |     |     |     |     |     |      |         |         |          |           |
| counter   |       | x     |     |      |     |        |     |     |     |     |     |      |         |         |          |           |
| histogram |       | x     | x   | x    | x   | x      | x   | x   | x   | x   | x   | x    |         |         |          |           |
| meter     |       | x     |     |      |     |        |     |     |     |     |     |      | r       | r       | r        | r         |
| timer     |       | x     | d   | d    | d   | d      | d   | d   | d   | d   | d   | d    | r       | r       | r        | r         |

where:

  • x is a plain value.
  • d represents a duration in duration_units.
  • r represents a rate in rate_units.

Example

name;kind;ts;value;count;max;mean;min;stddev;p50;p75;p95;p98;p99;p999;m1_rate;m5_rate;m15_rate;mean_rate;rate_unit;duration_unit
as.node.ignore.left.demand;counter;1572730123847;;1;;;;;;;;;;;;;;;second;milliseconds
as.node.ignore.left.downstream-finish;counter;1572730123847;;0;;;;;;;;;;;;;;;second;milliseconds

Contact

Grigorii Chudnov

License

Distributed under the The MIT License (MIT).

Versions

Version
1.0.1