Skip to content

Commit 7c141da

Browse files
committed
Reverted prometheus changes, bumped version, Updated documentation for new features
1 parent 9b93e45 commit 7c141da

File tree

4 files changed

+86
-64
lines changed

4 files changed

+86
-64
lines changed

README.md

+78-55
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,8 @@ Internal sinks are simple and built in as part of the metrics4j library.
589589

590590

591591
##### Slf4JMetricSink
592+
* _log-level:_ (INFO, DEBUG, WARN, ERROR, TRACE), log level to use when reporting metrics
593+
592594
Reports metrics to an Slf4j logger. The log-level attribute controls the log level (DEBUG, WARN, INFO, etc).
593595
```hocon
594596
sinks: {
@@ -599,9 +601,14 @@ sinks: {
599601
}
600602
```
601603

602-
* _log-level:_ (INFO, DEBUG, WARN, ERROR, TRACE), log level to use when reporting metrics
603604

604605
##### TelnetSink
606+
* _host:_ Host to connect to
607+
* _port:_ Port to use
608+
* _protocol:_ (UDP/**TCP**) Protocol to use
609+
* _max-udp-packet-size:_ (**1024**) Max packet size when using UDP
610+
* _resolution:_ (SECONDS/**MILLISECONDS**) If set to SECONDS this sink will use the 'put' command
611+
if set to MILLISECONDS the sink will use the 'putm' command
605612

606613
Sends data using the telnet protocol supported by OpenTSDB and KairosDB.
607614

@@ -619,15 +626,13 @@ sinks: {
619626
The resolution attribute can be either SECONDS or MILLISECONDS sending either a put or putm
620627
respectively
621628

629+
630+
##### GraphitePlaintextSink
631+
* _include-tags:_ includes tags for newer graphite version
622632
* _host:_ Host to connect to
623633
* _port:_ Port to use
624634
* _protocol:_ (UDP/**TCP**) Protocol to use
625635
* _max-udp-packet-size:_ (**1024**) Max packet size when using UDP
626-
* _resolution:_ (SECONDS/**MILLISECONDS**) If set to SECONDS this sink will use the 'put' command
627-
if set to MILLISECONDS the sink will use the 'putm' command
628-
629-
630-
##### GraphitePlaintextSink
631636

632637
Sends data using the plaintext protocol. It takes three attributes for host, port
633638
and whether to include tags.
@@ -643,21 +648,16 @@ sinks: {
643648
}
644649
```
645650

646-
* _include-tags:_ includes tags for newer graphite version
651+
652+
##### StatsDTCPSink
647653
* _host:_ Host to connect to
648654
* _port:_ Port to use
649655
* _protocol:_ (UDP/**TCP**) Protocol to use
650656
* _max-udp-packet-size:_ (**1024**) Max packet size when using UDP
651657

652-
##### StatsDTCPSink
653-
654658
Sends metrics to a StatsD instance. You can also set the source property _statsd_type_ to specify
655659
the type of metric, it defaults to 'g'
656660

657-
* _host:_ Host to connect to
658-
* _port:_ Port to use
659-
* _protocol:_ (UDP/**TCP**) Protocol to use
660-
* _max-udp-packet-size:_ (**1024**) Max packet size when using UDP
661661

662662
#### External
663663
External sinks are provided as plugins that have their own dependencies. These
@@ -668,6 +668,7 @@ The folder path is the location of the sink jar and all of its dependencies. A
668668
class loader is used for the sink so the dependencies will not interfere with the application.
669669

670670
##### InfluxSink
671+
* _host-url:_ url endpoint for influx
671672

672673
External sink for sending data to InfluxDB. Because both version 1 and 2 support the same
673674
line protocol you can switch between them by changing the host-url metrics are sent to.
@@ -682,9 +683,9 @@ sinks: {
682683
}
683684
```
684685

685-
* _host-url:_ url endpoint for influx
686686

687687
##### PrometheusSink
688+
* _listen-port:_ Port on which to listen for prometheus scrap requests
688689

689690
External sink that opens a port for a prometheus server to scrape the metrics from.
690691

@@ -710,9 +711,12 @@ triggers: {
710711
}
711712
```
712713

713-
* _listen-port:_ Port on which to listen for prometheus scrap requests
714714

715715
##### KairosSink
716+
* _host-url:_ (**http://localhost**) Url endpoint for sending http metrics to kairosdb
717+
* _telnet-host:_ (**null**) Telnet host to send metrics to kairosdb
718+
* _telnet-port:_ (**4242**) Telnet port
719+
* _ttl:_ (**0s**) Optional ttl. Can be specified like so "60s" or "24h", this can also be set as a prop in the source for specific metrics
716720

717721
External sink for sending data to KairosDB. Metrics can be sent either via http or telnet
718722
by specifying the appropriate configurations.
@@ -730,12 +734,10 @@ kairos: {
730734
Depending on which properties are set the sink will send either http or telnet using
731735
the kairosdb client.
732736

733-
* _host-url:_ (**http://localhost**) Url endpoint for sending http metrics to kairosdb
734-
* _telnet-host:_ (**null**) Telnet host to send metrics to kairosdb
735-
* _telnet-port:_ (**4242**) Telnet port
736-
* _ttl:_ (**0s**) Optional ttl. Can be specified like so "60s" or "24h", this can also be set as a prop in the source for specific metrics
737737

738738
##### OtelSink
739+
* _endpoint:_ (**http://localhost:4317**) Url for the grpc endpoint of the otlp collector.
740+
* _name:_ (**metrics4j**) Service name passed as part of the instrumentation scope info.
739741

740742
External Open Telemetry sink for sending metrics via OTLP using grpc protocol.
741743

@@ -750,8 +752,6 @@ sinks: {
750752
}
751753
```
752754

753-
* _endpoint:_ (**http://localhost:4317**) Url for the grpc endpoint of the otlp collector.
754-
* _name:_ (**metrics4j**) Service name passed as part of the instrumentation scope info.
755755

756756
##### TimescaleDBSink
757757

@@ -781,15 +781,19 @@ metrics4j {
781781
```
782782

783783
#### BagCollector
784+
* _report-unit:_ (NANOS, MICROS, **MILLIS**, SECONDS, MINUTES, HOURS, DAYS), set
785+
the units values are reported in. This only applies to Duration values. Can be set as a source property.
786+
* _report-format:_ (DOUBLE, **LONG**), set the format. Double is truncated at 3 decimals. Can be set as a source property.
787+
784788
This collector does not do any aggregation. Whatever value was put into the collector
785789
is reported using the time of the put or the Instant if one was provided.
786790
BagCollector can collect Long, Double, Duration and String values.
787791

788-
* _report-unit:_ (NANOS, MICROS, **MILLIS**, SECONDS, MINUTES, HOURS, DAYS), set
789-
the units values are reported in. This only applies to Duration values. Can be set as a source property.
790-
* _report-format:_ (DOUBLE, **LONG**), set the format. Double is truncated at 3 decimals. Can be set as a source property.
791792

792793
#### Chained Collectors
794+
* _collectors:_ List of collectors to chain together
795+
* _prefixes:_ Prefix to add to each collector respectively
796+
793797
There is a chain collector for each type of data: ChainedDoubleCollector,
794798
ChainedDurationCollector, ChainedLongCollector, ChainedStringCollector, ChainedTimeCollector
795799

@@ -823,75 +827,81 @@ metric being reported was `myMetric.value`, the chain collector would report two
823827
values `myMetric.count.value` and `myMetric.max.value`. The prefix is applied
824828
to the last part of the metric.
825829

826-
* _collectors:_ List of collectors to chain together
827-
* _prefixes:_ Prefix to add to each collector respectively
828830

829831
#### DoubleCounter
832+
* _reset:_ (true/false), when true the counter resets after reporting
833+
* _report-zero:_ (true/false), when set to false will not report zero values
834+
830835
Counts up double values to be reported. The counter can be reset when values are reported
831836
by setting reset: true in the conf
832837

833-
* _reset:_ (true/false), when true the counter resets after reporting
834-
* _report-zero:_ (true/false), when set to false will not report zero values
835838

836839
#### DoubleGauge
840+
* _reset:_ (true/false), when true the gauge sets to zero after reporting
841+
837842
Simple gauge that reports the most recently received value.
838843

839-
* _reset:_ (true/false), when true the gauge sets to zero after reporting
840844

841845
#### LastTime
846+
* _report-unit:_ (NANOS, MICROS, **MILLIS**, SECONDS, MINUTES, HOURS, DAYS), set
847+
the unites values are reported in. Can be set as a source property.
848+
* _report-format:_ (DOUBLE, **LONG**), set the format. Double is truncated at 3 decimals. Can be set as a source property.
849+
842850
LastTime collects Duration metrics and when reporting it simply reports the last
843851
Duration it received. The Duration is cleared once it is reported so it is
844852
only reported once.
845853

846-
* _report-unit:_ (NANOS, MICROS, **MILLIS**, SECONDS, MINUTES, HOURS, DAYS), set
847-
the unites values are reported in. Can be set as a source property.
848-
* * _report-format:_ (DOUBLE, **LONG**), set the format. Double is truncated at 3 decimals. Can be set as a source property.
849854

850855
#### LongCounter
856+
* _reset:_ (true/false), when true the counter resets after reporting
857+
* _report-zero:_ (true/false), when set to false will not report zero values
858+
851859
Counts up long values to be reported. The counter can be reset when values are reported
852860
by setting reset: true in the conf
853861

854-
* _reset:_ (true/false), when true the counter resets after reporting
855-
* _report-zero:_ (true/false), when set to false will not report zero values
856862

857863
#### LongGauge
864+
* _reset:_ (true/false), when true the gauge sets to zero after reporting
865+
858866
Simple gauge that reports the most recently received value.
859867

860-
* _reset:_ (true/false), when true the gauge sets to zero after reporting
861868

862869
#### MaxLongGauge
870+
* _reset:_ (true/false), when true the gauge sets to zero after reporting
871+
863872
Extends LongGauge and only stores and reports the max value over the reporting period.
864873

865-
* _reset:_ (true/false), when true the gauge sets to zero after reporting
866874

867875
#### NullCollector
868876
If you are familiar with /dev/null, this is the same concept. A way of turning
869877
off certain metrics.
870878

871879
#### PutCounter
880+
* _reset:_ (true/false), when true the counter resets after reporting
881+
* _report-zero:_ (true/false), when set to false will not report zero values
882+
872883
Counts the number of times the put method is called on a collector. Can be used
873884
with any data type.
874885

875-
* _reset:_ (true/false), when true the counter resets after reporting
876-
* _report-zero:_ (true/false), when set to false will not report zero values
877886

878887
#### SimpleStats
888+
* _report-zero:_ (true/false), when set to false will not report zero values
889+
879890
This reports the min, max, sum, count and avg for the set of values received since
880891
last reporting.
881892

882-
* _report-zero:_ (true/false), when set to false will not report zero values
883893

884894
#### SimpleTimerMetric
895+
* _report-unit:_ (NANOS, MICROS, **MILLIS**, SECONDS, MINUTES, HOURS, DAYS), set
896+
the units values are reported in. Can be set as a source property.
897+
* _report-format:_ (DOUBLE, **LONG**), set the format. Double is truncated at 3 decimals. Can be set as a source property.
898+
* _report-zero:_ (true/false), when set to false will not report zero values
899+
885900
Used for reporting measured durations. The collector reports min, max, total,
886901
count and avg for the measurements received during the last reporting period.
887902
Values are reported as milliseconds by default but maybe changed using the
888903
report-unit attribute. The report-unit and report-format can also be passed as a prop in the sources.
889904

890-
* _report-unit:_ (NANOS, MICROS, **MILLIS**, SECONDS, MINUTES, HOURS, DAYS), set
891-
the units values are reported in. Can be set as a source property.
892-
* _report-format:_ (DOUBLE, **LONG**), set the format. Double is truncated at 3 decimals. Can be set as a source property.
893-
* _report-zero:_ (true/false), when set to false will not report zero values
894-
895905
#### StringReporter
896906
No aggregation is done in this collector. All strings are reported with the time
897907
they were received.
@@ -903,6 +913,9 @@ provided. The deltas are recorded as a SimpleTimerMetric
903913
Takes the same parameters as SimpleTimerMetric
904914

905915
#### TimestampCounter
916+
* _increment-frequency:_ (20000) How often in milliseconds to increment the reporting timestamp. Default 20sec.
917+
* _bucket-size:_ (60000) Size of timestamp counting bucket. Default 1 min.
918+
906919
This collector records a count of timestamps during a configurable bucket of time.
907920
The initial use of this collector was to count events going in and out of an event
908921
system where each event had a timestamp set when it went in.
@@ -920,8 +933,6 @@ previous counts.
920933
For a detail description of how this works see:
921934
https://github.com/kairosdb/metrics4j/wiki/TimestampCounter
922935

923-
* _increment-frequency:_ (20000) How often in milliseconds to increment the reporting timestamp. Default 20sec.
924-
* _bucket-size:_ (60000) Size of timestamp counting bucket. Default 1 min.
925936

926937
### Formatters
927938
A formatter can change the name to your liking ie. underscore vs period
@@ -930,8 +941,21 @@ in the name.
930941
#### TemplateFormatter
931942
class = org.kairosdb.metrics4j.formatters.TemplateFormatter
932943

933-
Pass a template attribute where you can placeholders for className, methodName,
934-
field and specific tags.
944+
* _template:_ template to use when formatting metric names, see below.
945+
946+
TemplateFormatter lets you specify the resulting metric name using a template. Template
947+
variables are specified using `%{var}` syntax.
948+
949+
##### Template Variables
950+
* _className_ - Full class name from where the metric originated ie `com.project.MyStats`
951+
* _simpleClassName_ - Just the class name ie `MyStats`
952+
* _methodName_ - Name of the method called ie `uploadTime`
953+
* _field_ - The field from the collector ie `max` or `count`
954+
* _metricName_ - User specified field that is declared in the configuration. The value is
955+
specified in configuration using `_metric-name`
956+
* _tag._ - Provides a way to use a tag as part of the metric name ie `tag.host`
957+
958+
Sample template configuration:
935959

936960
```hocon
937961
formatters: {
@@ -942,8 +966,8 @@ formatters: {
942966
}
943967
```
944968

945-
You can also use metricName which can be specified within the source. This gives
946-
you the option to explicitly name a metrics
969+
Sample using user defined metricName:
970+
947971
```hocon
948972
formatters.CustomFormatter: {
949973
_class: "org.kairosdb.metrics4j.formatters.TemplateFormatter"
@@ -956,17 +980,19 @@ sources.com.kairosdb.CrazyClassNamePath: {
956980
```
957981

958982
**Note** The template formatter uses `%{}` so as to not be confused with `${}` used
959-
by hocon substitution - and so you can use both in a template. like so
983+
by hocon substitution - you can use both in a template. like so
960984
`template: ${metric-prefix}".%{className}.%{methodName}.%{tag.status}.%{field}"`
961985
You only quote the template replace portion.
962986

963-
* _template:_ template to use when formatting metric names, see above.
964987

965988
### Triggers
966989
The trigger tells metrics4j when to gather the metrics from the collectors and
967990
report to the sinks.
968991

969992
#### IntervalTrigger
993+
994+
* _interval:_ Set the trigger interval to gather metrics.
995+
970996
The IntervalTrigger lets you set a time for how often metrics are reported. The
971997
following reports metrics every 5 seconds. The interval property is a hocon duration.
972998
https://github.com/lightbend/config/blob/master/HOCON.md#duration-format
@@ -979,9 +1005,6 @@ triggers: {
9791005
}
9801006
```
9811007

982-
* _interval:_ Set the trigger interval to gather metrics.
983-
984-
9851008
### Plugins
9861009

9871010
#### JMXReporter

plugins/prometheus/pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@
5656
</dependency>
5757
<dependency>
5858
<groupId>io.prometheus</groupId>
59-
<artifactId>prometheus-metrics-core</artifactId>
60-
<version>1.3.4</version>
59+
<artifactId>simpleclient</artifactId>
60+
<version>0.16.0</version>
6161
</dependency>
6262
<dependency>
6363
<groupId>io.prometheus</groupId>
64-
<artifactId>prometheus-metrics-exporter-httpserver</artifactId>
65-
<version>1.3.4</version>
64+
<artifactId>simpleclient_httpserver</artifactId>
65+
<version>0.16.0</version>
6666
</dependency>
6767
</dependencies>
6868

plugins/prometheus/src/main/java/org/kairosdb/metrics4jplugin/prometheus/PrometheusSink.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.kairosdb.metrics4jplugin.prometheus;
22

3-
import io.prometheus.metrics.exporter.httpserver.HTTPServer;
4-
import io.prometheus.metrics.model.registry.PrometheusRegistry;
3+
import io.prometheus.client.Collector;
4+
import io.prometheus.client.CollectorRegistry;
5+
import io.prometheus.client.exporter.HTTPServer;
56
import lombok.Setter;
67
import org.kairosdb.metrics4j.MetricsContext;
78
import org.kairosdb.metrics4j.TriggerNotification;
@@ -56,8 +57,6 @@ public void init(MetricsContext context)
5657

5758
try
5859
{
59-
PrometheusRegistry
60-
HTTPServer.builder().registry()
6160
m_httpServer = new HTTPServer(new InetSocketAddress(listenPort), this, true);
6261
}
6362
catch (IOException e)

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
<properties>
3737
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38-
<revision>1.0.3-SNAPSHOT</revision>
38+
<revision>1.0.3</revision>
3939
<slf4j-version>2.0.12</slf4j-version>
4040
</properties>
4141

0 commit comments

Comments
 (0)