You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Steps to reproduce
When using the Prometheus exporter and initializing the Resource with the attribute opentelemetry.sdk.resources.SERVICE_NAME as suggested in the docs, a metric target_info gets exported with the attribute service.name.
Prometheus does not like the dot . in the attribute name and fails scraping the target.
Minimal code to reproduce the issue:
importtimefromprometheus_clientimportstart_http_serverfromopentelemetryimportmetricsfromopentelemetry.exporter.prometheusimportPrometheusMetricReaderfromopentelemetry.sdk.metricsimportMeterProviderfromopentelemetry.sdk.resourcesimportSERVICE_NAME, Resource# Service name is required for most backendsresource=Resource(attributes={
SERVICE_NAME: "your-service-name"
})
# Start Prometheus clientstart_http_server(port=8000, addr="localhost")
# Initialize PrometheusMetricReader which pulls metrics from the SDK# on-demand to respond to scrape requestsreader=PrometheusMetricReader()
provider=MeterProvider(resource=resource, metric_readers=[reader])
metrics.set_meter_provider(provider)
# Creates a meter from the global meter providermeter=metrics.get_meter("my.meter.name")
work_counter=meter.create_counter(
"work.counter", unit="1", description="Counts the amount of work done"
)
whileTrue:
work_counter.add(1, {"work.type": "Debug"})
print("doing some work...")
time.sleep(1)
When browsing to localhost:8000/metrics these are the metrics:
# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 356.0
python_gc_objects_collected_total{generation="1"} 289.0
python_gc_objects_collected_total{generation="2"} 0.0
# HELP python_gc_objects_uncollectable_total Uncollectable objects found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0
python_gc_objects_uncollectable_total{generation="1"} 0.0
python_gc_objects_uncollectable_total{generation="2"} 0.0
# HELP python_gc_collections_total Number of times this generation was collected
# TYPE python_gc_collections_total counter
python_gc_collections_total{generation="0"} 55.0
python_gc_collections_total{generation="1"} 4.0
python_gc_collections_total{generation="2"} 0.0
# HELP python_info Python platform information
# TYPE python_info gauge
python_info{implementation="CPython",major="3",minor="11",patchlevel="4",version="3.11.4"} 1.0
# HELP target_info Target metadata
# TYPE target_info gauge
target_info{service.name="your-service-name"} 1.0
# HELP work_counter_1_total Counts the amount of work done
# TYPE work_counter_1_total counter
work_counter_1_total{work_type="Debug"} 9.0
When checking the status of the target in the Prometheus UI, the following error is displayed: expected equal, got "." ("INVALID") while parsing: "target_info{service." because of the dot ..
What is the expected behavior?
The attribute of the metric target_info should not have a dot . in its name.
E.g. service_name.
What is the actual behavior?
The attribute of the metric target_info has a dot . in its name service.name (target_info{service.name="your-service-name"} 1.0).
The text was updated successfully, but these errors were encountered:
Describe your environment
Steps to reproduce
When using the Prometheus exporter and initializing the
Resource
with the attributeopentelemetry.sdk.resources.SERVICE_NAME
as suggested in the docs, a metrictarget_info
gets exported with the attributeservice.name
.Prometheus does not like the dot
.
in the attribute name and fails scraping the target.Minimal code to reproduce the issue:
When browsing to
localhost:8000/metrics
these are the metrics:When checking the status of the target in the Prometheus UI, the following error is displayed:
expected equal, got "." ("INVALID") while parsing: "target_info{service."
because of the dot.
.What is the expected behavior?
The attribute of the metric
target_info
should not have a dot.
in its name.E.g.
service_name
.What is the actual behavior?
The attribute of the metric
target_info
has a dot.
in its nameservice.name
(target_info{service.name="your-service-name"} 1.0
).The text was updated successfully, but these errors were encountered: