Integrating with Prometheus to collect metrics via API


Prometheus is an open-source system monitoring and alerting solution that collects and stores metrics as time-series data.

Configure a connection with Prometheus to view the metric data from Prometheus and derive actionable insights.

You can view the collected data in various BMC Helix applications and derive the following benefits:

BMC Helix application

Type of data collected or viewed

Benefits

BMC Helix Operations Management

Metrics

Use alarm and variate policies to detect anomalies and eliminate false positives for more accurate results while monitoring the health of your system.

For more information, see Detecting anomalies by using static and dynamic thresholds.

 

As a tenant administrator, perform the following steps to configure a connection with Prometheus, verify the connection, and view the collected data in various BMC Helix applications.

ConnectorSteps.png

Supported versions

BMC Helix Intelligent Integrations supports the following Prometheus versions for collecting metrics data via API:

  • Prometheus version 3.1
  • Prometheus version 2.36

Task 1: To plan for the connection

Review the following prerequisites to help you plan and configure a connection with Prometheus.

Prometheus prerequisite

BMC Helix Intelligent Integrations applies the mappings defined in the default JSLT to map the metrics received from
Prometheus metrics to the BMC Helix Operations Management attributes. However, you can customize the mappings
according to your requirements. Enter the customized JSLT when configuring the connection with Prometheus.

Click here to see a sample metrics JSON and the corresponding JSLT.

Sample data received from Prometheus

{
"namespace": "com.j9tech.prometheus.data",
"originTimestamp": 1737981876952,
"ingestTimestamp": 1737982185540,
"name": "kube_ingress_path",
"value": 1.0,
"unit": "Count",
"category": "Generic",
"quality": "Good",
"measurementGroup": [
"kubernetes-service-endpoints",
"10.xx.5.xxx:8080"
],
"extras": {
"path": "/",
"app_kubernetes_io_managed_by": "Helm",
"host": "alertmanager.aus.abc.com",
"job": "kubernetes-service-endpoints",
"instance": "10.xx.5.xxx:8080",
"service_port": "9093",
"argocd_argoproj_io_instance": "prometheus",
"__name__": "kube_ingress_path",
"helm_sh_chart": "kube-state-metrics-5.14.0",
"node": "aus-dsom-w3",
"app_kubernetes_io_component": "metrics",
"app_kubernetes_io_part_of": "kube-state-metrics",
"app_kubernetes_io_version": "2.10.0",
"namespace": "prometheus",
"apiEndpointUrl": "",
"ingress": "prometheus-alertmanager",
"app_kubernetes_io_instance": "prometheus",
"service_name": "prometheus-alertmanager",
"service": "prometheus-kube-state-metrics",
"app_kubernetes_io_name": "kube-state-metrics"
}
}

Sample JSLT

let extras = .extras
let jobString= fallback($extras.job,"")
let metricName = .name
let splitMetricData = split($metricName,"_")
let hostname = replaceFunkyCharacters(fallback($extras.instance,$extras.host))
def replaceFunkyCharacters(inputString)(
replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace($inputString," ","_"),"
\\(%\\)", "pct"),"%", "_pct_"),"\\*", "_"),"\\(", "_"),"\\)", "_"),",", "_"),"=", "_"),"'", "_"),"^:", "x:"),"
\\|", "_")
)
def getEntityName(spliitedMetricName,jobStr)(
if($spliitedMetricName[0] == $jobStr)
if($spliitedMetricName[1] != "")
$spliitedMetricName[1]
else
$spliitedMetricName[0]

else
$spliitedMetricName[0]
)
let ifName=fallback($extras.ifName,"")
let cpu=fallback($extras.cpu,"")
let mode=fallback($extras.mode,"")
let entityName=replaceFunkyCharacters(if($ifName != "")
$ifName+"_On_"+$hostname
else if($cpu != "" and $mode != "")
$mode
else if($cpu != "")
$metricName
else
getEntityName($splitMetricData,$jobString)
)
let finalMetricName=if($ifName != "")
$metricName
else if($cpu != "" and $mode != "")
$metricName+"_cpu_"+$cpu
else if($cpu != "")
$metricName+"_cpu_"+$cpu
else
$metricName
let keys=["job","state", "status", "version", "mode", "ifName", "alertname", "alertstate"]
def generateEntityTypeId()
(
[
for($keys)
"_"+get-key($extras,.,"") if(. != "job" and get-key($extras,.) != null)
]
)
let entityTypeId=replaceFunkyCharacters(get-key($extras,"job")+join(generateEntityTypeId(),""))
let metric={
"labels": {
"metricName": replaceFunkyCharacters($finalMetricName),
"hostname": $hostname,
"entityId":"Prometheus:"+$hostname+":"+$entityTypeId+":"+$entityName,
"entityTypeId": $entityTypeId,
"entityName": $entityName,
"hostType": "Server",
"isKpi": true,
"unit": .unit,
"source": "Prometheus",
"external_id":"PROMETHEUS_"+fallback($extras.instance,$extras.guaranteedInstance, "")
},
"samples": [
{
"value": number(.value),
"timestamp": number(.originTimestamp)
}
]
}
[$metric]

BMC Helix Intelligent Integrations prerequisites

  • Depending on the location of the third-party product (SaaS, on-premises), choose one or more BMC Helix
    Intelligent Integrations deployment modes and review the corresponding port requirements. For information
    about various deployment modes and port requirements, see Deployment scenarios.
  • Based on the deployment mode, use the BMC Helix Intelligent Integrations SaaS deployment or the BMC Helix
    Intelligent Integrations on-premises gateway or both. For more information about the gateway, see Deploying the
    BMC Helix Intelligent Integrations on-premises gateway
    .

Task 2: To configure the connection with Prometheus

  1. Depending on the deployment mode, perform one of the following steps to access BMC Helix Intelligent
    Integrations:
    • BMC Helix Intelligent Integrations SaaS – Log on to BMC Helix Portal, and click Launch on BMC Helix
      Intelligent Integrations.
    • BMC Helix Intelligent Integrations on-premises gateway – Use the following URL to access BMC Helix
      Intelligent Integrations: https://<hostName>:<portNumber>/swpui
  2. On the CONNECTORS tab, clickadd_icon.pngin the SOURCES panel .
  3. Click the Prometheus Metrics tile.
  4. Specify the following details for the source connection:
    1. Specify a unique instance name.

      Important

      We recommend that you specify the instance name in the following format:

      <sourceType>_<sourceControllerServerName>{_<InstanceQualifier>}

      The instance qualifier helps you to distinguish the multiple instances configured from the same source server. For example, you can name your instances as Prometheus_Host_PROD, Prometheus_Host_TEST, and so on.

    2. Specify the Prometheus metrics host name.
    3. Specify the Prometheus HTTP or HTTPS port number depending on the connection protocol (default value is 9090).
    4. Select the HTTPS option to use an https connection to the Prometheus   host.

      Important

      We recommend that you do not select the Allow Unsigned Certificate option in a production environment.  You might want to select this option to allow unsigned certificates in a test environment. See the Prometheus  documentation to learn how to install SSL certificates.

    5. Specify the number of maximum concurrent REST API requests that should be executed during a collection schedule (d efault value is 5).
    6. Specify the user name and password. Ensure that the specified user can access the Prometheus REST API.
    7. Click Proxy and specify whether you want to configure a proxy server.
      If yes, specify the host name and port number (default value is 8888).
  5. Click VALIDATE AND CREATE.
    The specified connection details are validated and the corresponding source connection is created in the Source Connection list.
  6. Select the source connection that you created from the list if it is not selected already.

    Important

    The destination host connection is created and configured automatically for each tenant when the source connection is created.

  7. Ensure that the options for the datatypes for which you want to collect data are selected.
  8. Click a data type and specify the configuration parameters in the Collectors section as described in the following table:

    Parameter name

    Description

    Data Type

    Prometheus Metrics

    Collection Schedule

    Select one of the following options to specify the data collection frequency:

    • Duration: When you select this option, data collection happens constantly. Specify the schedule in minutes, hours, or day. 
      Default: 5 minutes
      Example:
      Collection Schedule
      is set to 5 mins.
      Current time is 00:30.

      If you run the collector just after 00:30, data is collected every 5 mins, first at 00:30 and next at 00:35, and so on.  
    • Cron schedule: When you select this option, data collection happens periodically. Specify the schedule by using a cron expression.
      A cron expression is a string consisting of five subexpressions (fields) that describe individual details of the schedule.  
      These fields, separated by blank spaces, can contain any of the allowed values with various combinations of the allowed characters for that field.
      Default: */5 * * * * (evaluates to 5 minutes)

      Format:
      Minutes Hours (24-hour format) Day of Month Month Day of Week

      Example:
      If you specify 10 15 3 7 * , data is collected at 15:10 hours every third day in the month of July.

    For more information about how this parameter affects data collection, see Data collection schedule.

    ✅️

    Data Collection Window

    Specify the historical time period (in minutes) from the current time for which the data should be collected. 

    Default: 5 minutes (events and metrics), 60 minutes (topology)

    Example:

    Collection Schedule is set to 5 mins.
     Data Collection Window is set to 5 mins.
     Current time is 00:30.

    If you run the collector just after 00:30, data is collected first at 00:30 for the interval, 00:25 - 00:30, and next at 00:35 for the interval, 00:30 - 00:35, and so on.

    For more information about this parameter, see Data collection window .

    ✅️

    Data Latency

    Specify the time (in minutes) by which the data time window should be shifted back on the timeline.

    This parameter is useful in delayed data availability situations.

    Default: 0 minutes

    Example:

    Collection Schedule is set to 5 mins.
     Data Collection Window is set to 10 mins.
    Data Latency is set to 2 mins.
     Current time is 00:30.

    If you run the collector just after 00:30, data is collected first at 00:30 for the interval 00:18 to 00:28 and next at 00:35 for the interval 0:23 to 00:33, and so on.

    For more information about how this parameter affects data collection, see Data latency.

    ✅️

    Jobs

    Select all or a subset of jobs from the list.

    This list of jobs is updated automatically from Prometheus.

    ✅️

    Metric Namespaces

    Select all or a subset of metric namespaces from the list.

    This list of namespaces is updated automatically from Prometheus. 

    ✅️

    Label Name

    Select a label from the list.

    This list of labels is updated automatically from Prometheus. 

    ✅️

    Label Values

    Select all or a subset of label values from the list.

    ✅️

  9. Click CREATE COLLECTORS to create the required collector streams for the selected data type.
  10. Click a data type and specify the configuration parameters in the Distributors section as described in the following table:

    Parameter name

    Description

    Max Batching Size

    Specify the maximum number of data items to send in a single POST request to the destination API.
    The batch size 
    depends on the destination’s ability to buffer the incoming data.

    Default: 250

    Max Batching Delay

    Specify the maximum time (in seconds) to wait before building and processing a batch.

    Default: 3 seconds 

    Base Retry Delay

    Specify the initial time (in seconds) for which to wait before retrying to build and process a batch.
    The waiting time increases in the following sequence: n1, n2, n3, and so on, where n indicates the number of seconds.

    Default: 2 seconds

    Example: Base Retry Delay is set to 2 seconds. Retry is performed after 2, 4, 8, 16, ... seconds.

    Max Intra-Retry Delay

    Specify the maximum limit for the base retry delay. 

    Default: 60 seconds

    Example: Max Intra-Retry Delay is set to 60 seconds.
    Base Retry Delay is set to 2 seconds. Retries are performed 2, 4, 8, 16, 32,... seconds later.

    Max Retry Duration

    Specify the total time for retrying a delivery. For REST destinations, a delivery is a batch of data items in one POST request. 

    Default: 5 minutes

    Example: Max Retry Duration is set to 8 hours.
    Base Retry Delay is set to 2 seconds. Requests are sent for 2+4+8+16+32+64+132... until 8 hours in total duration is reached. After that, no subsequent attempts are made to retry the delivery. The assumption here is that if there is an outage or other issue with the destination tool, recovery should take less than the value of the Max Retry Duration parameter to be completed.

    Attributes To Be Dropped When Updating Events

    Specify the event attributes that you do not want to be updated in BMC Helix Operations Management when events are updated. For example, if you do not want an event's severity, source address, source category, and subcategory to be updated in BMC Helix Operations Management, you need to specify those attributes in a comma-separated format: severity,source_address,source_category,source_subcategory.

    Important:You can obtain the event attribute names in BMC Helix Operations Management, by exporting any event data in JSON, BAROC, XML, or CSV format. The exported file contains all attributes of the event data, and from there you can identify the attributes to be dropped. 

  11. Click CREATE DISTRIBUTORS to create the required distributor streams for the selected data type.
  12. Click VALIDATE AND CREATE and then click SAVE STREAM to save the stream.
    After you save the stream, the connection that you just created is listed on the SOURCES panel.
  13. (Optional) Perform the following steps if you want to use the custom JSLT that you have prepared according to the sample shown in Prometheus prerequisite. Otherwise, skip to step 14.
    1. On the SOURCES panel, click Configure Mediator ConfigureMediator_icon.pngfor the source connection that you created and then expand PROMETHEUS METRICS and navigate to the DISTRIBUTOR CONFIGURATION tab.
    2. To view JSON in the edit mode, click Edit JSON.
    3. Search for the following line:

       "jsltField": "//NO JSLT",
    4. Delete the existing value from the jsltField field; the result should look as follows:

      "jsltField": "",
    5. To disable the edit mode for JSON, click Edit JSON.
    6. In the JSLT field, enter the customized JSLT.  
    7. Click SAVE & CLOSE.
  14. On the SOURCES panel, move the slider to the right to start the data stream for the connector you created.

Important
For a data stream, the Run Latency (max/avg), Items (Avg per Run), and Last Run Status columns on the
Streams page might show the status as No Runs during the data collection process. After completion of
the process, these columns are updated with an appropriate status.

For more information about data streams, see Starting-or-stopping-data-streams.

Task 3: To verify the integration

In BMC Helix Intelligent Integrations , on the SOURCES panel, confirm that the data streams for the integration you created are running. Data streaming is indicated by moving colored arrows.

Prometheus_MetricStream.png

A moving red arrow (MetricsStream_Icon.png) indicates that the metric stream is running. Metric data will be pushed according to the configured Collection Schedule interval.

To view metrics in BMC Helix Operations Management

  1. In BMC Helix Operations Management, select Monitoring > Devices.
  2. Click the links for the required device.
  3. On the Monitors tab, click the required monitor.
    The Performance Overview tab shows the metrics graph.
    Prometheus_Metrics.png
    For information about metrics, see Viewing collected data.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*