5.23 API for scrape of Exporter used by JP1/IM - Agent
- Description
-
Scrape each exporter that you want to scrape on the Prometheus server. Scrape is performed at the interval set in item "scrape_interval" of the Prometheus configuration file (jpc_prometheus_server.yml).
Even if a status code other than 200 is returned, it will not be retried.
- Communication method
-
Communication protocol: HTTP
Port number: Exporter's port number
- Format
-
- Request line
GET /metrics# HTTP/1.1
The only communication protocol is "HTTP". Specifies the port number of the exporter.
- #
-
The "/metrics" part can be changed in item "metrics_path" of [scrape_configs] of the Prometheus configuration file (jpc_prometheus_server.yml).
- Request header
-
Header name
Setup values
host
The value of the item "targets" in the Prometheus configuration file (jpc_prometheus_server.yml) is set.
user-agent
Prometheus/2.23.0 is set.
accept
"application/openmetrics-text; version=0.0.1,text/plain;version=0.0.4;q=0.5,*/*;q=0.1" is set.
accept-encoding
"gzip" is set.
x-prometheus-scrape-timeout-seconds
The value of the item "scrape_timeout" in the Prometheus configuration file (jpc_prometheus_server.yml) is set.
Other
Authentication information is added according to the settings of the Prometheus configuration file (jpc_prometheus_server.yml).
- Request message body
-
None
- Response message body
-
Returns information in the Prometheus text format shown below.
■Basic Information
Items
Description
Supported Prometheus versions
0.40 or later
Communication protocol
HTTP
Encoding
UTF-8
Use the newline character "\n".
HTTP Content Data Format (Content-Type)
text/plain; version=0.0.4
If there is no version value, it is treated as the latest text format version.
HTTP Content Encoding (Optional) -
gzip
Supported metrics
-
Counter
-
Gauge
-
Histogram
-
Summary
-
Untyped
■Text formatting details
-
Written line-by-line.
-
The newline character at the end of a line must be '\n'.
-
Empty lines are ignored.
■Row formatting
-
Tokens on a single line can be separated by any number of spaces or tabs.
-
Leading and trailing whitespace is ignored.
■Comments,Help Text,Type Information
-
Lines beginning with "#" are treated as comments. Lines where the token immediately after the "#" is not "HELP" or type information are ignored.
-
If the token immediately following the "#" is "HELP", at least one token with the metric name is required. All remaining tokens are considered descriptive for that metric name.
Lines of help text can contain any UTF-8 string after the metric name, but backslashes (\) and newline characters (\n) must be escaped, such as "\\" and "\\n".
Only one line of help text can be written per metric name.
-
If the token immediately following the "#" is type information, describe two or more tokens. The first is the metric name, and the second is counter, gauge, histogram, summary, or untyped, which defines the type of metric.
Only one line of type information can be described per metric name.
A row of type information must appear before the first sample for the metric name on that row.
If no line of type information exists for a metric name, the type of the metric is set to "untyped".
■Sample syntax
metric_name [ "{" label_name "=" `"` label_value `"` { "," label_name "=" `"` label_value `"` } [ "," ] "}" ] value [ timestamp ]
-
metric_name and label_name have the limitations of normal Prometheus writing.
-
label_value can be any UTF-8 string. Backslashes (\), double quotes ("), and line feeds must be escaped as "\\", "\"", and "\\n", respectively.
-
value is a floating-point number required by Go's ParseFloat() function. In addition to regular numbers, NaN (not numeric), +Inf (positive infinity), and -Inf (negative infinity) values are also valid.
-
The timestamp is int64 (milliseconds (excluding leap seconds) since 1970-01-01 00:00:00 UTC). It is displayed as needed in Go's ParseInt() function.
■Grouping and sorting
-
All rows for a metric must be provided as a group, along with an optional help text line and a line of type information.
-
Each row must be a unique combination of metric name and label.
■Examples of text formatting
# HELP http_requests_total The total number of HTTP requests. # TYPE http_requests_total counter http_requests_total{method="post",code="200"} 1027 1395066363000 http_requests_total{method="post",code="400"} 3 1395066363000 # Escaping in label values: msdos_file_access_time_seconds{path="C:\\DIR\\FILE.TXT",error="Cannot find file:\n\"FILE.TXT\""} 1.458255915e9 # Minimalistic line: metric_without_timestamp_and_labels 12.47 # A weird metric from before the epoch: something_weird{problem="division by zero"} +Inf -3982045 # A histogram, which has a pretty complex representation in the text format: # HELP http_request_duration_seconds A histogram of the request duration. # TYPE http_request_duration_seconds histogram http_request_duration_seconds_bucket{le="0.05"} 24054 http_request_duration_seconds_bucket{le="0.1"} 33444 http_request_duration_seconds_bucket{le="0.2"} 100392 http_request_duration_seconds_bucket{le="0.5"} 129389 http_request_duration_seconds_bucket{le="1"} 133988 http_request_duration_seconds_bucket{le="+Inf"} 144320 http_request_duration_seconds_sum 53423 http_request_duration_seconds_count 144320 # Finally a summary, which has a complex representation, too: # HELP rpc_duration_seconds A summary of the RPC duration in seconds. # TYPE rpc_duration_seconds summary rpc_duration_seconds{quantile="0.01"} 3102 rpc_duration_seconds{quantile="0.05"} 3272 rpc_duration_seconds{quantile="0.5"} 4773 rpc_duration_seconds{quantile="0.9"} 9001 rpc_duration_seconds{quantile="0.99"} 76656 rpc_duration_seconds_sum 1.7560473e+07 rpc_duration_seconds_count 2693
-