I am using OpenTelemetry’s Metrics to get information about my environment.
I have several tenants that will use OpenTelemetry and will all be ingested into Prometheus and then Grafana.
I would like to differentiate between each one by adding some king of label/tag/attribute.
I am using the configuration below, but when I expose the /metrics endpoint using the UseOpenTelemetryPrometheusScrapingEndpoint
extension method, the attribute is not shown.
services.AddOpenTelemetry()
.WithMetrics(opts =>
{
opts.ConfigureResource(resourceBuilder =>
{
resourceBuilder.AddTelemetrySdk();
resourceBuilder.AddService(serviceName: "tenant_service_config");
resourceBuilder.AddAttributes(new Dictionary<string, object> { ["tenant_id"] = 2 });
})
.AddMeter(meters.MetricName)
.AddAspNetCoreInstrumentation()
.AddProcessInstrumentation()
.AddRuntimeInstrumentation();
However, if I manually create a Metric and add a tag, it does show up in the /metrics endpoint
_userLoginCounter.Add(1, new KeyValuePair<string, object>("tenant.id", tenantId));
Adri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.