Class Info
java.lang.Object
io.prometheus.metrics.core.metrics.Metric
io.prometheus.metrics.core.metrics.MetricWithFixedMetadata
io.prometheus.metrics.core.metrics.Info
- All Implemented Interfaces:
Collector
Info metric. Example:
Info info = Info.builder()
.name("java_runtime_info")
.help("Java runtime info")
.labelNames("env", "version", "vendor", "runtime")
.register();
String version = System.getProperty("java.runtime.version", "unknown");
String vendor = System.getProperty("java.vm.vendor", "unknown");
String runtime = System.getProperty("java.runtime.name", "unknown");
info.addLabelValues("prod", version, vendor, runtime);
info.addLabelValues("dev", version, vendor, runtime);
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class io.prometheus.metrics.core.metrics.MetricWithFixedMetadata
labelNamesFields inherited from class io.prometheus.metrics.core.metrics.Metric
constLabels -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLabelValues(String... labelValues) Create an info data point with the given label values.static Info.Builderbuilder()static Info.Builderbuilder(PrometheusProperties config) collect()Called when the Prometheus server scrapes metrics.Returns the metric type for registration-time validation.voidRemove the data point with the specified label values.voidsetLabelValues(String... labelValues) Set the info label values.Methods inherited from class io.prometheus.metrics.core.metrics.MetricWithFixedMetadata
getLabelNames, getMetadata, getPrometheusName
-
Field Details
-
labels
-
-
Constructor Details
-
Info
-
-
Method Details
-
setLabelValues
Set the info label values. This will replace any previous values, i.e. the info metric will only have one data point after calling setLabelValues(). This is good for a metric liketarget_infowhere you want only one single data point. -
addLabelValues
Create an info data point with the given label values. -
remove
Remove the data point with the specified label values. -
collect
Description copied from interface:CollectorCalled when the Prometheus server scrapes metrics. -
getMetricType
Description copied from interface:CollectorReturns the metric type for registration-time validation.This is used to prevent different metric types (e.g., Counter and Gauge) from sharing the same name. Returning
nullmeans type validation is skipped for this collector.Validation is performed only at registration time. If this method returns
null, no type validation is performed for this collector, and duplicate or conflicting metrics may result in invalid exposition output.- Returns:
- the metric type, or
nullto skip validation
-
builder
-
builder
-