Configuring SNMP Metrics

When configuring SNMP metrics, you must define one or more Prometheus HTTP endpoints to poll, and one or more mapping rules to convert the Prometheus metric data into SNMP metrics.

The Prometheus HTTP endpoints are represented by the HTTP URLs that the application exposes to be polled by a Prometheus server.

Prometheus Endpoints shows the properties you can define for use when polling URLs by a Prometheus server.

Table 1. Prometheus Endpoints
Property Name Description Default Value
snmp-adapter.prometheusMetrics.endpoints[0].url The full URL of the Prometheus endpoint.
snmp-adapter.prometheusMetrics.endpoints[0].pollingFrequency The interval between each read of the Prometheus endpoint. Postfix the value with an s to indicate seconds, m for minutes, or ms for milliseconds. 5s

The example below shows a sample Prometheus endpoint configuration in a YAML configuration file.

snmp-adapter:
  prometheusMetrics:
    endpoints:
      - url: 'http://localhost:9098/metrics'
        pollingFrequency: 5s

Notice that the properties include an array style index. This allows multiple endpoint configurations to be added.

Mapping Rules

When the Prometheus metric data is retrieved from the endpoint, you must define how to convert this data to SNMP metrics. To do this, you must select a Prometheus metric name. A metric name can appear several times in the output, with different tags, as shown in the example output below. You may require restricting the matches by defining the tags to match on (for example, matching a static value or using a regular expression). The values of all the matching metric entries are added together before being exposed as SNMP metrics.

The following shows example output from the SBA Gateway Prometheus endpoint.

# HELP vertx_pool_usage_seconds Time using a resource 
# TYPE vertx_pool_usage_seconds summary 
vertx_pool_usage_seconds_count{application="sba-5gc-networkfunctionschf",
pool_type="worker",} 1.0 
vertx_pool_usage_seconds_sum{application="sba-5gc-networkfunctionschf",
pool_type="worker",} 5.563319696 
# HELP vertx_pool_usage_seconds_max Time using a resource 
# TYPE vertx_pool_usage_seconds_max gauge 
vertx_pool_usage_seconds_max{application="sba-5gc-networkfunctionschf",
pool_type="worker",} 0.0 
# HELP jvm_memory_max_bytes The maximum amount of memory in bytes that can be used for 
memory management 
# TYPE jvm_memory_max_bytes gauge 
jvm_memory_max_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="CodeHeap 'non-nmethods'",} 5836800.0 
jvm_memory_max_bytes{application="sba-5gc-networkfunctions-chf",area="heap",id="G1 Old 
Gen",} 8.321499136E9 
jvm_memory_max_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="Compressed Class Space",} 1.073741824E9 
jvm_memory_max_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 1.22912768E8 
jvm_memory_max_bytes{application="sba-5gc-networkfunctions-chf",area="heap",id="G1 
Survivor Space",} -1.0 
jvm_memory_max_bytes{application="sba-5gc-networkfunctions-chf",area="heap",id="G1 Eden 
Space",} -1.0 
jvm_memory_max_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="Metaspace",} -1.0 
jvm_memory_max_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="CodeHeap 'profiled nmethods'",} 1.22908672E8 
# HELP process_start_time_seconds Start time of the process since unix epoch. 
# TYPE process_start_time_seconds gauge 
process_start_time_seconds{application="sba-5gc-networkfunctions-chf",} 1.638281797357E9 
# HELP process_uptime_seconds The uptime of the Java virtual machine 
# TYPE process_uptime_seconds gauge 
process_uptime_seconds{application="sba-5gc-networkfunctions-chf",} 174137.141 
# HELP process_files_open_files The open file descriptor count 
# TYPE process_files_open_files gauge 
process_files_open_files{application="sba-5gc-networkfunctions-chf",} 89.0 
# HELP jvm_threads_live_threads The current number of live threads including both daemon 
and non-daemon threads 
# TYPE jvm_threads_live_threads gauge 
jvm_threads_live_threads{application="sba-5gc-networkfunctions-chf",} 32.0 
# HELP process_files_max_files The maximum file descriptor count 
# TYPE process_files_max_files gauge 
process_files_max_files{application="sba-5gc-networkfunctions-chf",} 1048576.0 
# HELP vertx_http_server_request_bytes_max Size of requests in bytes 
# TYPE vertx_http_server_request_bytes_max gauge 
vertx_http_server_request_bytes_max{application="sba-5gc-networkfunctions-
chf",method="GET",} 0.0 
vertx_http_server_request_bytes_max{application="sba-5gc-networkfunctions-
chf",method="POST",} 0.0 
# HELP vertx_http_server_request_bytes Size of requests in bytes 
# TYPE vertx_http_server_request_bytes summary 
vertx_http_server_request_bytes_count{application="sba-5gc-networkfunctions-
chf",method="GET",} 45719.0 
vertx_http_server_request_bytes_sum{application="sba-5gc-networkfunctions-
chf",method="GET",} 0.0 
vertx_http_server_request_bytes_count{application="sba-5gc-networkfunctions-
chf",method="POST",} 4.0 
vertx_http_server_request_bytes_sum{application="sba-5gc-networkfunctions-
chf",method="POST",} 124.0 
# HELP jvm_buffer_count_buffers An estimate of the number of buffers in the pool 
# TYPE jvm_buffer_count_buffers gauge 
jvm_buffer_count_buffers{application="sba-5gc-networkfunctions-chf",id="mapped",} 0.0 
jvm_buffer_count_buffers{application="sba-5gc-networkfunctions-chf",id="direct",} 20.0 
# HELP jvm_gc_max_data_size_bytes Max size of long-lived heap memory pool 
# TYPE jvm_gc_max_data_size_bytes gauge 
jvm_gc_max_data_size_bytes{application="sba-5gc-networkfunctions-chf",} 8.321499136E9 
# HELP jvm_memory_committed_bytes The amount of memory in bytes that is committed for the 
Java virtual machine to use 
# TYPE jvm_memory_committed_bytes gauge 
jvm_memory_committed_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="CodeHeap 'non-nmethods'",} 2555904.0 
jvm_memory_committed_bytes{application="sba-5gc-networkfunctions-chf",area="heap",id="G1 
Old Gen",} 2.5165824E8 
jvm_memory_committed_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="Compressed Class Space",} 7766016.0 
jvm_memory_committed_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 1.1599872E7 
jvm_memory_committed_bytes{application="sba-5gc-networkfunctions-chf",area="heap",id="G1 
Survivor Space",} 4194304.0 
jvm_memory_committed_bytes{application="sba-5gc-networkfunctions-chf",area="heap",id="G1 
Eden Space",} 4.21527552E8 
jvm_memory_committed_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="Metaspace",} 6.168576E7 
jvm_memory_committed_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="CodeHeap 'profiled nmethods'",} 2.1561344E7 
# HELP system_cpu_count The number of processors available to the Java virtual machine 
# TYPE system_cpu_count gauge 
system_cpu_count{application="sba-5gc-networkfunctions-chf",} 12.0 
# HELP jvm_gc_live_data_size_bytes Size of long-lived heap memory pool after reclamation 
# TYPE jvm_gc_live_data_size_bytes gauge 
jvm_gc_live_data_size_bytes{application="sba-5gc-networkfunctions-chf",} 5.4206888E7 
# HELP vertx_http_server_response_bytes_max Size of responses in bytes 
# TYPE vertx_http_server_response_bytes_max gauge 
vertx_http_server_response_bytes_max{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/healthcheck",} 69.0 
vertx_http_server_response_bytes_max{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/metrics",} 18332.0 
vertx_http_server_response_bytes_max{application="sba-5gc-networkfunctionschf",
code="405",method="GET",route="",} 0.0 
vertx_http_server_response_bytes_max{application="sba-5gc-networkfunctionschf",
code="404",method="POST",route="",} 0.0 
# HELP vertx_http_server_response_bytes Size of responses in bytes 
# TYPE vertx_http_server_response_bytes summary 
vertx_http_server_response_bytes_count{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/healthcheck",} 34108.0 
vertx_http_server_response_bytes_sum{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/healthcheck",} 2353452.0 
vertx_http_server_response_bytes_count{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/metrics",} 11610.0 
vertx_http_server_response_bytes_sum{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/metrics",} 2.12171744E8 
vertx_http_server_response_bytes_count{application="sba-5gc-networkfunctionschf",
code="405",method="GET",route="",} 1.0 
vertx_http_server_response_bytes_sum{application="sba-5gc-networkfunctionschf",
code="405",method="GET",route="",} 0.0 
vertx_http_server_response_bytes_count{application="sba-5gc-networkfunctionschf",
code="404",method="POST",route="",} 4.0 
vertx_http_server_response_bytes_sum{application="sba-5gc-networkfunctionschf",
code="404",method="POST",route="",} 212.0 
# HELP jvm_threads_daemon_threads The current number of live daemon threads 
# TYPE jvm_threads_daemon_threads gauge 
jvm_threads_daemon_threads{application="sba-5gc-networkfunctions-chf",} 5.0 
# HELP vertx_http_server_response_time_seconds_max Request processing time 
# TYPE vertx_http_server_response_time_seconds_max gauge 
vertx_http_server_response_time_seconds_max{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/healthcheck",} 6.2512E-5 
vertx_http_server_response_time_seconds_max{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/metrics",} 0.00289529 
vertx_http_server_response_time_seconds_max{application="sba-5gc-networkfunctionschf",
code="405",method="GET",route="",} 0.0 
vertx_http_server_response_time_seconds_max{application="sba-5gc-networkfunctionschf",
code="404",method="POST",route="",} 0.0 
# HELP vertx_http_server_response_time_seconds Request processing time 
# TYPE vertx_http_server_response_time_seconds summary 
vertx_http_server_response_time_seconds_count{application="sba-5gc-networkfunctions
chf",code="200",method="GET",route="/healthcheck",} 34108.0 
vertx_http_server_response_time_seconds_sum{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/healthcheck",} 2.360600295 
vertx_http_server_response_time_seconds_count{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/metrics",} 11610.0 
vertx_http_server_response_time_seconds_sum{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/metrics",} 24.077576507 
vertx_http_server_response_time_seconds_count{application="sba-5gc-networkfunctionschf",
code="405",method="GET",route="",} 1.0 
vertx_http_server_response_time_seconds_sum{application="sba-5gc-networkfunctionschf",
code="405",method="GET",route="",} 6.21446E-4 
vertx_http_server_response_time_seconds_count{application="sba-5gc-networkfunctionschf",
code="404",method="POST",route="",} 4.0 
vertx_http_server_response_time_seconds_sum{application="sba-5gc-networkfunctionschf",
code="404",method="POST",route="",} 0.024258753 
# HELP jvm_threads_states_threads The current number of threads having NEW state 
# TYPE jvm_threads_states_threads gauge 
jvm_threads_states_threads{application="sba-5gc-networkfunctions-chf",state="timedwaiting",} 
2.0 
jvm_threads_states_threads{application="sba-5gc-networkfunctionschf",
state="terminated",} 0.0 
jvm_threads_states_threads{application="sba-5gc-networkfunctions-chf",state="runnable",} 
28.0 
jvm_threads_states_threads{application="sba-5gc-networkfunctions-chf",state="new",} 0.0 
jvm_threads_states_threads{application="sba-5gc-networkfunctions-chf",state="waiting",} 
2.0 
jvm_threads_states_threads{application="sba-5gc-networkfunctions-chf",state="blocked",} 
0.0 
# HELP log4j2_events_total Number of fatal level log events 
# TYPE log4j2_events_total counter 
log4j2_events_total{application="sba-5gc-networkfunctions-chf",level="fatal",} 0.0 
log4j2_events_total{application="sba-5gc-networkfunctions-chf",level="info",} 150187.0 
log4j2_events_total{application="sba-5gc-networkfunctions-chf",level="trace",} 0.0 
log4j2_events_total{application="sba-5gc-networkfunctions-chf",level="warn",} 34775.0 
log4j2_events_total{application="sba-5gc-networkfunctions-chf",level="error",} 34752.0 
log4j2_events_total{application="sba-5gc-networkfunctions-chf",level="debug",} 69783.0 
# HELP jvm_buffer_memory_used_bytes An estimate of the memory that the Java virtual 
machine is using for this buffer pool 
# TYPE jvm_buffer_memory_used_bytes gauge 
jvm_buffer_memory_used_bytes{application="sba-5gc-networkfunctions-chf",id="mapped",} 0.0 
jvm_buffer_memory_used_bytes{application="sba-5gc-networkfunctions-chf",id="direct",} 
2.0142365E8 
# HELP vertx_http_server_active_connections Number of opened connections to the server 
# TYPE vertx_http_server_active_connections gauge 
vertx_http_server_active_connections{application="sba-5gc-networkfunctions-chf",} 2.0 
# HELP jvm_gc_memory_promoted_bytes_total Count of positive increases in the size of the 
old generation memory pool before GC to after GC 
# TYPE jvm_gc_memory_promoted_bytes_total counter 
jvm_gc_memory_promoted_bytes_total{application="sba-5gc-networkfunctions-chf",} 
6.1075624E7 
# HELP vertx_pool_completed_total Number of elements done with the resource 
# TYPE vertx_pool_completed_total counter 
vertx_pool_completed_total{application="sba-5gc-networkfunctionschf",
pool_type="worker",} 1.0 
# HELP system_cpu_usage The "recent cpu usage" for the whole system 
# TYPE system_cpu_usage gauge 
system_cpu_usage{application="sba-5gc-networkfunctions-chf",} 0.08675629503082523 
# HELP vertx_http_server_requests_total Number of processed requests 
# TYPE vertx_http_server_requests_total counter 
vertx_http_server_requests_total{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/healthcheck",} 34108.0 
vertx_http_server_requests_total{application="sba-5gc-networkfunctionschf",
code="200",method="GET",route="/metrics",} 11610.0 
vertx_http_server_requests_total{application="sba-5gc-networkfunctionschf",
code="405",method="GET",route="",} 1.0 
vertx_http_server_requests_total{application="sba-5gc-networkfunctionschf",
code="404",method="POST",route="",} 4.0 
# HELP jvm_memory_used_bytes The amount of used memory 
# TYPE jvm_memory_used_bytes gauge 
jvm_memory_used_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="CodeHeap 'non-nmethods'",} 1704832.0 
jvm_memory_used_bytes{application="sba-5gc-networkfunctions-chf",area="heap",id="G1 Old 
Gen",} 5.4726128E7 
jvm_memory_used_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="Compressed Class Space",} 6999112.0 
jvm_memory_used_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 1.1593856E7 
jvm_memory_used_bytes{application="sba-5gc-networkfunctions-chf",area="heap",id="G1 
Survivor Space",} 4194304.0 
jvm_memory_used_bytes{application="sba-5gc-networkfunctions-chf",area="heap",id="G1 Eden 
Space",} 6.9206016E7 
jvm_memory_used_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="Metaspace",} 5.969308E7 
jvm_memory_used_bytes{application="sba-5gc-networkfunctionschf",
area="nonheap",id="CodeHeap 'profiled nmethods'",} 2.1545344E7 
# HELP jvm_gc_memory_allocated_bytes_total Incremented for an increase in the size of the 
(young) heap memory pool after one GC to before the next 
# TYPE jvm_gc_memory_allocated_bytes_total counter 
jvm_gc_memory_allocated_bytes_total{application="sba-5gc-networkfunctions-chf",} 
5.399117824E10 
# HELP vertx_http_server_bytes_read_total Number of bytes received by the server 
# TYPE vertx_http_server_bytes_read_total counter 
vertx_http_server_bytes_read_total{application="sba-5gc-networkfunctions-chf",} 124.0 
# HELP vertx_pool_queue_pending Number of pending elements in queue 
# TYPE vertx_pool_queue_pending gauge 
vertx_pool_queue_pending{application="sba-5gc-networkfunctions-chf",pool_type="worker",} 
0.0 
# HELP process_cpu_usage The "recent cpu usage" for the Java Virtual Machine process 
# TYPE process_cpu_usage gauge 
process_cpu_usage{application="sba-5gc-networkfunctions-chf",} 2.9708853238265005E-4 
# HELP vertx_eventbus_handlers Number of event bus handlers in use 
# TYPE vertx_eventbus_handlers gauge 
vertx_eventbus_handlers{application="sba-5gc-networkfunctions-chf",} 38.0 
# HELP jvm_buffer_total_capacity_bytes An estimate of the total capacity of the buffers 
in this pool 
# TYPE jvm_buffer_total_capacity_bytes gauge 
jvm_buffer_total_capacity_bytes{application="sba-5gc-networkfunctions-chf",id="mapped",} 
0.0 
jvm_buffer_total_capacity_bytes{application="sba-5gc-networkfunctions-chf",id="direct",} 
2.01431841E8 
# HELP vertx_http_server_active_requests Number of requests being processed 
# TYPE vertx_http_server_active_requests gauge 
vertx_http_server_active_requests{application="sba-5gc-networkfunctions-
chf",method="GET",} 1.0 
vertx_http_server_active_requests{application="sba-5gc-networkfunctions-
chf",method="POST",} 0.0 
# HELP vertx_pool_in_use Number of resources used 
# TYPE vertx_pool_in_use gauge 
vertx_pool_in_use{application="sba-5gc-networkfunctions-chf",pool_type="worker",} 0.0 
# HELP vertx_pool_ratio Pool usage ratio, only present if maximum pool size could be 
determined 
# TYPE vertx_pool_ratio gauge 
vertx_pool_ratio{application="sba-5gc-networkfunctions-chf",pool_type="worker",} 0.0 
# HELP jvm_classes_loaded_classes The number of classes that are currently loaded in the 
Java virtual machine 
# TYPE jvm_classes_loaded_classes gauge 
jvm_classes_loaded_classes{application="sba-5gc-networkfunctions-chf",} 9729.0 
# HELP jvm_threads_peak_threads The peak live thread count since the Java virtual machine 
started or peak was reset 
# TYPE jvm_threads_peak_threads gauge 
jvm_threads_peak_threads{application="sba-5gc-networkfunctions-chf",} 32.0 
# HELP vertx_pool_queue_time_seconds_max Time spent in queue before being processed 
# TYPE vertx_pool_queue_time_seconds_max gauge 
vertx_pool_queue_time_seconds_max{application="sba-5gc-networkfunctionschf",
pool_type="worker",} 0.0 
# HELP vertx_pool_queue_time_seconds Time spent in queue before being processed 
# TYPE vertx_pool_queue_time_seconds summary 
vertx_pool_queue_time_seconds_count{application="sba-5gc-networkfunctions
chf",pool_type="worker",} 1.0 
vertx_pool_queue_time_seconds_sum{application="sba-5gc-networkfunctionschf",
pool_type="worker",} 0.004830115 
# HELP jvm_gc_pause_seconds Time spent in GC pause 
# TYPE jvm_gc_pause_seconds summary 
jvm_gc_pause_seconds_count{action="end of minor GC",application="sba-5gcnetworkfunctions-
chf",cause="G1 Evacuation Pause",} 138.0 
jvm_gc_pause_seconds_sum{action="end of minor GC",application="sba-5gc-networkfunctionschf",
cause="G1 Evacuation Pause",} 0.529 
jvm_gc_pause_seconds_count{action="end of minor GC",application="sba-5gcnetworkfunctions-
chf",cause="Metadata GC Threshold",} 1.0 
jvm_gc_pause_seconds_sum{action="end of minor GC",application="sba-5gc-networkfunctionschf",
cause="Metadata GC Threshold",} 0.006 
# HELP jvm_gc_pause_seconds_max Time spent in GC pause 
# TYPE jvm_gc_pause_seconds_max gauge 
jvm_gc_pause_seconds_max{action="end of minor GC",application="sba-5gc-networkfunctionschf",
cause="G1 Evacuation Pause",} 0.0 
jvm_gc_pause_seconds_max{action="end of minor GC",application="sba-5gc-networkfunctionschf",
cause="Metadata GC Threshold",} 0.0 
# HELP vertx_http_server_bytes_written_total Number of bytes sent by the server 
# TYPE vertx_http_server_bytes_written_total counter 
vertx_http_server_bytes_written_total{application="sba-5gc-networkfunctions-chf",} 
2.14525408E8 
# HELP jvm_classes_unloaded_classes_total The total number of classes unloaded since the 
Java virtual machine has started execution 
# TYPE jvm_classes_unloaded_classes_total counter 
jvm_classes_unloaded_classes_total{application="sba-5gc-networkfunctions-chf",} 0.0 
# HELP system_load_average_1m The sum of the number of runnable entities queued to 
available processors and the number of runnable entities running on the available 
processors averaged over a period of time 
# TYPE system_load_average_1m gauge 
system_load_average_1m{application="sba-5gc-networkfunctions-chf",} 1.43 

Properties for Converting Prometheus Metric Data from Endpoints to SNMP Metrics shows the properties that are used to convert Prometheus metric data to SNMP metrics.

Table 2. Properties for Converting Prometheus Metric Data from Endpoints to SNMP Metrics
Property Name Description
snmp-adapter.prometheusMetrics.mappings[0].metricName The name of the Prometheus metric.
snmp-adapter.prometheusMetrics.mappings[0].oid The OID of the SNMP metric.
snmp-adapter.prometheusMetrics.mappings[0].selectors[0].tagName The name of the Prometheus tag to select on.
snmp-adapter.prometheusMetrics.mappings[0].selectors[0].tagValue The exact value that the Prometheus tag must have.
snmp-adapter.prometheusMetrics.mappings[0].selectors[0].tagValuePattern The regular expression that the Prometheus tag value must match.

The example below shows a sample mapping rule configuration in a YAML configuration file.

snmp-adapter:
  prometheusMetrics:
    mappings:
 
 
      # Total Converged Charging Notify Requests
      - metricName: 'sba_chf_notify_requests_total'
        oid: '1.3.6.1.4.1.35838.1.6.2.9.1'
        selectors:
          - tagName: 'notificationType'
            tagValue: 'ChargingNotifyRequest'
 
      # Total Failed Converged Charging Notify Requests
      - metricName: 'sba_chf_notify_requests_total'
        oid: '1.3.6.1.4.1.35838.1.6.2.10.1'
        selectors:
          - tagName: 'notificationType'
            tagValue: 'ChargingNotifyRequest'
          - tagName: 'httpStatus'
            tagValuePattern: '^[4-5][0-9]{2}$'    # Any 4xx or 5xx HTTP Response Code

Notice that the properties include an array style index at two points. This allows multiple mapping rules to be added, and also allows each rule to define multiple tag selectors.