Collect Metrics
The Sumo Logic Distribution for OpenTelemetry Collector provides various receivers for metrics collection. The full list of OpenTelemetry receivers are available on OpenTelemetry collector repository.
To use a receiver, define it in the receivers: section, then reference it in a pipeline. Place your configuration files in the conf.d directory.
Host metrics
The following example uses the Host Metrics receiver to collect system-level metrics like CPU, memory, and disk usage:
receivers:
hostmetrics/linux/localhost:
scrapers:
cpu:
metrics:
system.cpu.utilization:
enabled: true
load: null
memory:
metrics:
system.memory.utilization:
enabled: true
disk: null
filesystem:
metrics:
system.filesystem.utilization:
enabled: true
network: null
paging: null
process:
mute_process_name_error: true
metrics:
process.threads:
enabled: true
process.paging.faults:
enabled: true
process.cpu.utilization:
enabled: true
process.memory.utilization:
enabled: true
process.signals_pending:
enabled: true
process.open_file_descriptors:
enabled: true
process.context_switches:
enabled: true
process.disk.operations:
enabled: true
processors:
resource/linux_resource_attributes/localhost:
attributes:
- key: sumo.datasource
value: linux
action: insert
service:
pipelines:
metrics/linux/localhost:
receivers:
- hostmetrics/linux/localhost
processors:
- memory_limiter
- resource/linux_resource_attributes/localhost
- resourcedetection/system
- batch
exporters:
- sumologic
Prometheus metrics
If you have applications that expose metrics in Prometheus format, you can scrape them using the prometheus receiver. This is the recommended approach for collecting Prometheus metrics with the Sumo Logic OpenTelemetry Collector.
If you're migrating from a Telegraf-based collection setup, see Collect Prometheus Metrics for the older Telegraf-based approach.
The following example scrapes metrics from an application running on localhost:8080:
receivers:
prometheus:
config:
scrape_configs:
- job_name: 'my-app-metrics'
scrape_interval: 10s
static_configs:
- targets: ['localhost:8080']
service:
pipelines:
metrics:
receivers: [prometheus]
exporters: [sumologic]
This configuration:
- Defines a
prometheusreceiver that scrapes metrics fromlocalhost:8080every 10 seconds. - Creates a metrics pipeline that sends the scraped metrics to Sumo Logic via the
sumologicexporter.
You can add multiple targets under static_configs to scrape from several endpoints, or add additional scrape_configs entries for different jobs:
receivers:
prometheus:
config:
scrape_configs:
- job_name: 'app-1'
scrape_interval: 10s
static_configs:
- targets: ['app1-host:9090']
- job_name: 'app-2'
scrape_interval: 30s
static_configs:
- targets: ['app2-host:9090', 'app2-host:9091']
Once your metrics are flowing into Sumo Logic, you can visualize them in a dashboard and set up monitors to alert on threshold breaches.
You'll need to restart the collector process in order to apply changes.
Refer to our Additional Configurations Reference for more details about OpenTelemetry configuration.