Business metrics (Public Preview)
You can use OpenTelemetry (OTel) to transmit business metrics data directly in OTLP format from your applications or systems to the Instana backend.
Prerequisites
Identify your Instana deployment region because the backend endpoint is region-dependent. To find your environment-specific Instana region, from the navigation menu in the Instana UI, click More > About Instana. The Instana dialog displays your deployment region.
Each Instana SaaS environment is associated with a specific region name, such as blue, red, green, orange, or coral. For more information about the endpoint of the Instana backend otlp-acceptor, see Endpoints of Instana backend otlp-acceptor.
Sending metrics by using OTLP
To send metrics by using OTLP format, complete the following steps:
- Install the OpenTelemetry SDK and the OTLP exporter for your programming language.
- Configure the OTLP exporter.
a. Set the OTLP endpoint. For more information, see
Endpoints of Instana backend otlp-acceptor.
b. Set the following mandatory headers:
-
"x-instana-key": "your-instana-agent-key" -
"x-instana-host": "-" -
"x-instana-metric-category": "business"
-
- Initialize the metrics provider, and attach a metric
exporter(for example,
PeriodicExportingMetricReader) to handle the metrics data that are sent periodically. - Define and record a gauge metric. The gauge metric type is the only supported option. Include attributes as needed.
Example: Sending business metrics to the Instana backend directly by using the OTEL Python SDK package
pip install opentelemetry-sdk
pip install opentelemetry-exporter-otlp
from opentelemetry.metrics import (
get_meter_provider,
set_meter_provider,
)
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
# Define mandatory headers
headers = {
"x-instana-key": "xxx",
"x-instana-host": "-",
"x-instana-metric-category": "business"
}
exporter = OTLPMetricExporter(endpoint="https://{INSTANA_OTLP_GRPC_BACKEND}:4317", headers=headers, insecure=True)
reader = PeriodicExportingMetricReader(exporter)
provider = MeterProvider(metric_readers=[reader])
set_meter_provider(provider)
# Define customer segment as an attribute
attributes = {
"customer_segment": "enterprise",
}
# Get the meter and define a revenue gauge
meter = get_meter_provider().get_meter("Company.Department", version="1.0", attributes=attributes)
gauge = meter.create_gauge(
"Revenue",
unit="USD"
)
# Set the revenue value (e.g., $50,000)
gauge.set(50000, attributes)