Skip to content

Commit

Permalink
Adds k8s01 prefix to collected app-specific metrics (#92)
Browse files Browse the repository at this point in the history
* Adds k8s_01 prefix to collected app-specific metrics

* Remove underscore from metrics prefix

* Remove underscore from metrics prefix#2
  • Loading branch information
StrongestNumber9 authored Aug 2, 2023
1 parent ab36f8d commit 48a9b56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/main/java/com/teragrep/k8s_01/PrometheusMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ public PrometheusMetrics(int port) {
ServletHolder servletHolder = new ServletHolder(metricsServlet);
context.addServlet(servletHolder, "/metrics");

// TODO: Prefix to be configurable?
// Totals
metricRegistry.register(name("total", "reconnects"), new Counter());
metricRegistry.register(name("total", "connections"), new Counter());
metricRegistry.register(name("k8s01", "total", "reconnects"), new Counter());
metricRegistry.register(name("k8s01", "total", "connections"), new Counter());

// Throughput meters
metricRegistry.register(name("throughput", "bytes"), new Meter(new SlidingTimeWindowMovingAverages()));
metricRegistry.register(name("throughput", "records"), new Meter(new SlidingTimeWindowMovingAverages()));
metricRegistry.register(name("throughput", "errors"), new Meter(new SlidingTimeWindowMovingAverages()));
metricRegistry.register(name("k8s01", "throughput", "bytes"), new Meter(new SlidingTimeWindowMovingAverages()));
metricRegistry.register(name("k8s01", "throughput", "records"), new Meter(new SlidingTimeWindowMovingAverages()));
metricRegistry.register(name("k8s01", "throughput", "errors"), new Meter(new SlidingTimeWindowMovingAverages()));

// Misc
metricRegistry.register(name("jvm", "vm"), new JvmAttributeGaugeSet());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/teragrep/k8s_01/RelpOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ public class RelpOutput {
relpConnection.setReadTimeout(relpConfig.getReadTimeout());
relpConnection.setWriteTimeout(relpConfig.getWriteTimeout());
// Throughput
throughputBytes = metricRegistry.meter(name("throughput", "bytes"));
throughputRecords = metricRegistry.meter(name("throughput", "records"));
throughputErrors = metricRegistry.meter(name("throughput", "errors"));
throughputBytes = metricRegistry.meter(name("k8s01", "throughput", "bytes"));
throughputRecords = metricRegistry.meter(name("k8s01", "throughput", "records"));
throughputErrors = metricRegistry.meter(name("k8s01", "throughput", "errors"));

// Totals
totalConnections = metricRegistry.counter(name("total", "connections"));
totalReconnects = metricRegistry.counter(name("total", "reconnects"));
totalConnections = metricRegistry.counter(name("k8s01", "total", "connections"));
totalReconnects = metricRegistry.counter(name("k8s01", "total", "reconnects"));
connect();
}

Expand Down

0 comments on commit 48a9b56

Please sign in to comment.