Skip to content

Script Development / Prometheus

The Prometheus connector operation objects mainly provide some methods for operating Prometheus.

This connector is based on HTTP protocol to access Prometheus

Parameters for DFF.CONN(...) are as follows:

Parameter Type Required / Default Value Description
connector_id str Required Connector ID

.query(...)

Sends an HTTP request to Prometheus. The parameters are as follows:

Parameter Type Required / Default Value Description
method str Required Request method: GET, POST, etc.
path str None Request path
query dict None Request URL parameters
body dict None Request body
Example
1
2
3
4
5
6
result = prom.query('GET', '/api/v1/query_range', query={
  'query': 'up',
  'start': '2024-01-01T00:00:00Z',
  'end'  : '2024-01-02T00:00:00Z',
  'step' : '60s',
})

This method is a parameter pass-through

This method is actually a parameter pass-through and does not perform any processing itself.

For more information about the Prometheus HTTP API, please refer to Prometheus Official Documentation / Querying / HTTP API