Package id.opentelemetry.exporters
Class ElasticsearchMetricExporter
Object
ElasticsearchMetricExporter
- All Implemented Interfaces:
AggregationTemporalitySelector
,DefaultAggregationSelector
,MetricExporter
,Closeable
,AutoCloseable
Push Metric Exporter to ElasticSearch.
It is based on Java HttpClient
and sends all metrics using ElastiSearch
Bulk API
Measurements are aggregated with AggregationTemporality.DELTA
Currently supporter metric types:
MetricDataType.LONG_SUM
MetricDataType.HISTOGRAM
Export schema is based on field names given in ExportSchema
.
If ElasticSearch has self-signed SSL certificates by default Java will not allow to connect to
it. Use ElasticsearchMetricExporter(URI, Optional, Duration, boolean)
with insecure set
to "true".
Usage
var metricReader = PeriodicMetricReader
.builder(new ElasticsearchMetricExporter(
URI.create("https://localhost:9200/mymetrics"), Optional.of(new Credentials("elastic", "pass"))))
.setInterval(Duration.ofSeconds(3))
.build();
var sdkMeterProvider = SdkMeterProvider.builder()
.registerMetricReader(metricReader).build();
OpenTelemetrySdk.builder()
.setMeterProvider(sdkMeterProvider)
.buildAndRegisterGlobal();
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionElasticsearchMetricExporter
(URI elasticSearch) ElasticsearchMetricExporter
(URI elasticSearch, Optional<ElasticsearchMetricExporter.Credentials> credentials) ElasticsearchMetricExporter
(URI elasticSearch, Optional<ElasticsearchMetricExporter.Credentials> credentials, Duration timeout, boolean insecure) -
Method Summary
Modifier and TypeMethodDescriptionCompletableResultCode
export
(Collection<MetricData> metrics) CompletableResultCode
flush()
AggregationTemporality
getAggregationTemporality
(InstrumentType instrumentType) CompletableResultCode
shutdown()
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface DefaultAggregationSelector
with
Methods inherited from interface MetricExporter
close, getDefaultAggregation, getMemoryMode
-
Constructor Details
-
ElasticsearchMetricExporter
- Parameters:
elasticSearch
- URI to the ElasticSearch index where metrics will be exported. Credentials can be part of the URL. Example http://user:password@localhost:9200/customers They are optional to allow anonymous access if it is enabled on ElasticSearch.
-
ElasticsearchMetricExporter
public ElasticsearchMetricExporter(URI elasticSearch, Optional<ElasticsearchMetricExporter.Credentials> credentials) - Parameters:
credentials
- ElasticSearch user and password. They are optional to allow anonymous access if it is enabled on ElasticSearch.
-
ElasticsearchMetricExporter
public ElasticsearchMetricExporter(URI elasticSearch, Optional<ElasticsearchMetricExporter.Credentials> credentials, Duration timeout, boolean insecure) - Parameters:
insecure
- allow connections to ElasticSearch with self-signed SSL certificates
-
-
Method Details
-
export
- Specified by:
export
in interfaceMetricExporter
-
flush
public CompletableResultCode flush()- Specified by:
flush
in interfaceMetricExporter
-
shutdown
public CompletableResultCode shutdown()- Specified by:
shutdown
in interfaceMetricExporter
-
getAggregationTemporality
public AggregationTemporality getAggregationTemporality(InstrumentType instrumentType) - Specified by:
getAggregationTemporality
in interfaceAggregationTemporalitySelector
-