All Projects → ricoberger → Script_exporter

ricoberger / Script_exporter

Licence: mit
Prometheus exporter to execute scripts and collect metrics from the output or the exit status.

Programming Languages

go
31211 projects - #10 most used programming language
script
160 projects

Projects that are alternatives of or similar to Script exporter

Iperf3 exporter
Simple server that probes iPerf3 endpoints and exports results via HTTP for Prometheus consumption
Stars: ✭ 30 (-64.29%)
Mutual labels:  prometheus, prometheus-exporter
Ansible Prometheus
Ansible playbook for installing Prometheus monitoring system, exporters such as: node, snmp, blackbox, thus alert manager and push gateway
Stars: ✭ 69 (-17.86%)
Mutual labels:  prometheus, prometheus-exporter
Kafka exporter
Kafka exporter for Prometheus
Stars: ✭ 996 (+1085.71%)
Mutual labels:  prometheus, prometheus-exporter
Zk Exporter
Exposes monitoring metrics for Apache Zookeeper to Prometheus
Stars: ✭ 27 (-67.86%)
Mutual labels:  prometheus, prometheus-exporter
Windows exporter
Prometheus exporter for Windows machines
Stars: ✭ 1,230 (+1364.29%)
Mutual labels:  prometheus, prometheus-exporter
Unifiedmetrics
Fully-featured metrics collection agent for Minecraft servers. Supports Prometheus and InfluxDB. Dashboard included out-of-box.
Stars: ✭ 29 (-65.48%)
Mutual labels:  prometheus, prometheus-exporter
Ssh exporter
A Prometheus exporter for running SSH commands on a remote host and collecting statistics on those outputs
Stars: ✭ 40 (-52.38%)
Mutual labels:  prometheus, prometheus-exporter
Ebpf exporter
Prometheus exporter for custom eBPF metrics
Stars: ✭ 829 (+886.9%)
Mutual labels:  prometheus, prometheus-exporter
Druid Exporter
A Golang based exporter captures druid API related metrics and receives druid-emitting HTTP JSON data.
Stars: ✭ 54 (-35.71%)
Mutual labels:  prometheus, prometheus-exporter
Unifi Poller
Application: Collect ALL UniFi Controller, Site, Device & Client Data - Export to InfluxDB or Prometheus
Stars: ✭ 1,050 (+1150%)
Mutual labels:  prometheus, prometheus-exporter
Prometheus Tor exporter
Prometheus exporter for the TOR daemon
Stars: ✭ 20 (-76.19%)
Mutual labels:  prometheus, prometheus-exporter
Ebpf exporter
A Prometheus exporter which uses eBPF to measure block IO request latency / size
Stars: ✭ 56 (-33.33%)
Mutual labels:  prometheus, prometheus-exporter
Json Exporter
Prometheus exporter which fetches JSON from a URL and exports one of the values as gauge metrics
Stars: ✭ 26 (-69.05%)
Mutual labels:  prometheus, prometheus-exporter
Citrix Adc Metrics Exporter
Export metrics from Citrix ADC (NetScaler) to Prometheus
Stars: ✭ 67 (-20.24%)
Mutual labels:  prometheus, prometheus-exporter
Postgresql exporter
A Prometheus exporter for some postgresql metrics
Stars: ✭ 26 (-69.05%)
Mutual labels:  prometheus, prometheus-exporter
Promcord
📊 Analyze your entire discord guild in grafana using prometheus. Message, User, Game and Voice statistics...
Stars: ✭ 39 (-53.57%)
Mutual labels:  prometheus, prometheus-exporter
Statsd exporter
StatsD to Prometheus metrics exporter
Stars: ✭ 608 (+623.81%)
Mutual labels:  prometheus, prometheus-exporter
Snmp exporter
SNMP Exporter for Prometheus
Stars: ✭ 705 (+739.29%)
Mutual labels:  prometheus, prometheus-exporter
Phpfpm exporter
Prometheus exporter for PHP-FPM.
Stars: ✭ 51 (-39.29%)
Mutual labels:  prometheus, prometheus-exporter
Unifi exporter
Multiarch images for scraping Prometheus metrics from a Unifi Controller. Kubernetes / prometheus-operator compatible.
Stars: ✭ 54 (-35.71%)
Mutual labels:  prometheus, prometheus-exporter

script_exporter

The script_exporter is a Prometheus exporter to execute scripts and collect metrics from the output or the exit status. The scripts to be executed are defined via a configuration file. In the configuration file several scripts can be specified. The script which should be executed is indicated by a parameter in the scrap configuration. The output of the script is captured and is provided for Prometheus. Even if the script does not produce any output, the exit status and the duration of the execution are provided.

Building and running

To run the script_exporter you can use the one of the binaries from the release page or the Docker image. You can also build the script_exporter by yourself by running the following commands:

git clone https://github.com/ricoberger/script_exporter.git
cd script_exporter
make build

An example configuration can be found in the examples folder. To use this configuration run the following command:

./bin/script_exporter -config.file ./examples/config.yaml

Then visit http://localhost:9469 in the browser of your choice. There you have access to the following examples:

  • test: Invalid values which are returned by the script are omitted.
  • ping: Pings the specified address in the target parameter and returns if it was successful or not.
  • helloworld: Returns the specified argument in the script as label.
  • showtimeout: Reports whether or not the script is being run with a timeout from Prometheus, and what it is.
  • docker: Example using docker exec to return the number of files in a Docker container.
  • metrics: Shows internal metrics from the script exporter.

You can also deploy the script_exporter to Kubernetes. An example Deployment file can be found here: examples/kubernetes.yaml.

Usage and configuration

The script_exporter is configured via a configuration file and command-line flags.

Usage of ./bin/script_exporter:
  -config.file file
    	Configuration file in YAML format. (default "config.yaml")
  -create-token
    	Create bearer token for authentication.
  -timeout-offset seconds
        Offset to subtract from Prometheus-supplied timeout in seconds. (default 0.5)
  -version
    	Show version information.
  -web.listen-address string
    	Address to listen on for web interface and telemetry. (default ":9469")

The configuration file is written in YAML format, defined by the scheme described below.

tls:
  enabled: <boolean>
  crt: <string>
  key: <string>

basicAuth:
  enabled: <boolean>
  username: <string>
  password: <string>

bearerAuth:
  enabled: <boolean>
  signingKey: <string>

scripts:
  - name: <string>
    script: <string>
    # optional
    timeout:
      # in seconds, 0 or negative means none
      max_timeout: <float>
      enforced: <boolean>

The name of the script must be a valid Prometheus label value. The script string will be split on spaces to generate the program name and any fixed arguments, then any arguments specified from the params parameter will be appended. The program will be executed directly, without a shell being invoked, and it is recommended that it be specified by path instead of relying on $PATH.

Prometheus will normally provide an indication of its scrape timeout to the script exporter (through a special HTTP header). This information is made available to scripts through the environment variables $SCRIPT_TIMEOUT and $SCRIPT_DEADLINE. The first is the timeout in seconds (including a fractional part) and the second is the Unix timestamp when the deadline will expire (also including a fractional part). A simple script could implement this timeout by starting with timeout "$SCRIPT_TIMEOUT" cmd .... A more sophisticated program might want to use the deadline time to compute internal timeouts for various operation. If enforced is true, script_exporter attempts to enforce the timeout by killing the script's main process after the timeout expires. The default is to not enforce timeouts. If max_timeout is set for a script, it limits the maximum timeout value that requests can specify; a request that specifies a larger timeout will have the timeout adjusted down to the max_timeout value.

For testing purposes, the timeout can be specified directly as a URL parameter (timeout). If present, the URL parameter takes priority over the Prometheus HTTP header.

Prometheus configuration

The script_exporter needs to be passed the script name as a parameter (script). You can also pass a custom prefix (prefix) which is prepended to metrics names and the names of additional parameters which should be passed to the script (params and then additional URL parameters). If the output parameter is set to ignore then the script_exporter only return script_success{} and script_duration_seconds{}.

The params parameter is a comma-separated list of additional URL query parameters that will be used to construct the additional list of arguments, in order. The value of each URL query parameter is not parsed or split; it is passed directly to the script as a single argument.

Example config:

scrape_configs:
  - job_name: 'script_test'
    metrics_path: /probe
    params:
      script: [test]
      prefix: [script]
    static_configs:
      - targets:
        - 127.0.0.1
    relabel_configs:
      - target_label: script
        replacement: test
  - job_name: 'script_ping'
    scrape_interval: 1m
    scrape_timeout: 30s
    metrics_path: /probe
    params:
      script: [ping]
      prefix: [script_ping]
      params: [target]
      output: [ignore]
    static_configs:
      - targets:
        - example.com
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - target_label: __address__
        replacement: 127.0.0.1:9469
      - source_labels: [__param_target]
        target_label: target
      - source_labels: [__param_target]
        target_label: instance

  - job_name: 'script_exporter'
    metrics_path: /metrics
    static_configs:
      - targets:
        - 127.0.0.1:9469

Breaking changes

Changes from version 1.3.0:

  • The command line flag -web.telemetry-path has been removed and its value is now always /probe, which is a change from the previous default of /metrics. The path /metrics now responds with Prometheus metrics for script_exporter itself.
  • The command line flag -config.shell has been removed. Programs are now always run directly.

Dependencies

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].