http_check

metrics
 

This source can be used for synthetic checks against HTTP endpoints. This source will make a request to the specified endpoint using the configured method. This scraper generates metrics with a label for each HTTP response status class with a value of 1 if the status code matches the class.

Example

# Targets to probe
#
# Required
targets: 
- http://127.0.0.1:8080

# TLS configuration
#
# Optional
tls: 
  # Absolute path to an additional CA certificate file, in DER or PEM
  # format(X.509), or an inline CA certificate in PEM format.
  #
  # Optional
  ca: null

  # Absolute path to a certificate file used to identify this connection,
  # in DER or PEM format (X.509) or PKCS#12, or an inline certificate in
  # PEM format. If this is set and is not a PKCS#12 archive, "key_file"
  # must also be set.
  #
  # Optional
  cert: null

  # Absolute path to a private key file used to identify this connection,
  # in DER or PEM format (PKCS#8), or an inline private key in PEM format.
  # If this is set, "crt_file" must also be set.
  #
  # Optional
  key: null

  # Pass phrase used to unlock the encrypted key file. This has no effect
  # unless "key" is set.
  #
  # Optional
  key_pass: null

  # Enables certificate verification.
  # If enabled, certificates must not be expired and must be issued by a trusted issuer.
  # This verification operates in a hierarchical manner, checking that the leaf certificate
  # (the certificate presented by the client/server) is not only valid, but that the issuer
  # of that certificate is also valid, and so on until the verification process reaches a
  # root certificate.
  # 
  # Relevant for both incoming and outgoing connections.
  # 
  # Do NOT set this to false unless you understand the risks of not verifying the
  # validity of certificates.
  #
  # Optional
  verify_certificate: true

  # Enables hostname verification. If enabled, the hostname used to connect to the remote
  # host must be present in the TLS certificate presented by the remote host, either as the
  # Common Name or as an entry in the Subject Alternative Name extension.
  # 
  # Only relevant for outgoing connections.
  # 
  # Do NOT set this to false unless you understand the risks of not verifying the remote hostname.
  #
  # Optional
  verify_hostname: true

# The authentication strategy for http request/response
#
# Optional
auth: 
  strategy: basic

  # The basic authentication username.
  #
  # Required
  user: ""

  # The basic authentication password.
  #
  # Required
  password: ""

# Extra HTTP headers
#
# Optional
headers: {}

# Timeout for HTTP request, it's value should be less than `interval`.
#
# Optional
timeout: 5s

# This sources collects metrics on an interval.
#
# Optional
interval: 15s

Output

# HELP http_duration_seconds Duration of http request by phase
# TYPE http_duration_seconds gauge
http_duration_seconds{instance="www.aliyun.com",phase="connect"} 0.008719786
http_duration_seconds{instance="www.aliyun.com",phase="processing"} 0.052432433
http_duration_seconds{instance="www.aliyun.com",phase="resolve"} 0.005326997
http_duration_seconds{instance="www.aliyun.com",phase="tls"} 0.024979751
http_duration_seconds{instance="www.aliyun.com",phase="transfer"} 0.028581304
# HELP http_last_modified_timestamp_seconds Returns the Last-Modified HTTP response header in unixtime
# TYPE http_last_modified_timestamp_seconds gauge
http_last_modified_timestamp_seconds{instance="www.aliyun.com"} 1762250059
# HELP http_redirects The number of redirects
# TYPE http_redirects gauge
http_redirects{instance="www.aliyun.com"} 0
# HELP http_status_code Response HTTP status code
# TYPE http_status_code gauge
http_status_code{instance="www.aliyun.com"} 200
# HELP http_up Whether the target is success
# TYPE http_up gauge
http_up{instance="www.aliyun.com"} 1
# HELP http_version Returns the version of HTTP of the probe response
# TYPE http_version gauge
http_version{instance="www.aliyun.com"} 1.1