Skip to content

OSSHelp/ansible-script-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

script-exporter

Build Status

Role for script_exporter installation and configuration.

Usage (example)

    - role: script-exporter
      script_exporter_scripts:
        - { name: "some_script", path: "/path/to/script", sudo: false }
        - { name: "another_script", path: "/path/to/another/script", sudo: true }

Available parameters

Main

Short description here.

Param Default Description
script_exporter_setup full Setup mode. See OSSHelp KB article
script_exporter_scripts See defaults Array, describing scripts for exporter to be able to launch. If sudo param is set to true - corresponding entry will be generated in sudoers.d and the target script will be run with sudo

FAQ

Passing script-name in params

Use location like this:

location ~/(.+)/(.+)/metrics$ {
    if ($args ~ "script=.+") {
        rewrite ^/(.+)/(.+)/metrics$ /probe?$args break;
        proxy_pass http://$1-$2-exporter;
    }
    rewrite ^/(.+)/(.+)/metrics$ /metrics break;
    proxy_pass http://$1-$2-exporter;
}

Upstream for this location:

upstream container-name-script-exporter {
    server container-name:9469;
}

Replace the container-name with appropriate name here.

Struggling with Prometheus setup

Job for prometheus.yml should be like this, nothing special:

- job_name: script-exporter
  metrics_path: /metrics
  scrape_interval: 60s
  scheme: http
  relabel_configs:
  - source_labels:
    - __address__
    regex: ^(.+)\.\w+\.\w+:\d+
    target_label: instance
    action: replace
  file_sd_configs:
  - files:
    - /etc/prometheus/targets/script-exporter/*.yml
    refresh_interval: 5m

The tricky part is the include itself, template:

- targets:
  - 'server-alias.ossdata.ru'
  labels:
    __scheme__: http
    __metrics_path__: /container-name/script/metrics
    __param_script: "script-alias"
    job: script-exporter
    env: production
    group: somegroup
    project: project-name
    instance: server-alias
    source: container-name

script-alias here is a name, used for script in script-exporter's cfg.

Useful links

TODO

  • improve this readme (quick'n'dirty for now)

License

GPL3

Author

OSSHelp Team, see https://oss.help