项目作者: scaleway

项目描述 :
Prometheus Service Discovery for Scaleway
高级语言: Go
项目地址: git://github.com/scaleway/prometheus-scw-sd.git
创建时间: 2018-07-27T12:57:00Z
项目社区:https://github.com/scaleway/prometheus-scw-sd

开源协议:Apache License 2.0

下载


A service discovery for the Scaleway cloud platform compatible with Prometheus.

Credits to Simon Pasquier who wrotes most of the code on his own repository before merging it into this one.

How it works

This service gets the list of servers from the Scaleway API and generates a file which is compatible with the Prometheus file_sd mechanism.

Pre-requisites

You need your Scaleway secret key (token). You can create this token in the console.

Installing it

Download the binary from the Releases page.

Running it

  1. usage: sd adapter usage --scw.token-file=my-token.txt [<flags>]
  2. Tool to generate Prometheus file_sd target files for Scaleway.
  3. Flags:
  4. -h, --help Show context-sensitive help (also try --help-long and --help-man).
  5. --output.file="scw.json" The output filename for file_sd compatible file.
  6. --scw.organization=SCW.ORGANIZATION
  7. The Scaleway organization.
  8. --scw.region="par1" The Scaleway region. Leaving blank will fetch from all the regions.
  9. --scw.token-file="" The authentication token file containing Scaleway Secret Key.
  10. --target.refresh=30 The refresh interval (in seconds).
  11. --target.port=80 The default port number for targets.
  12. --web.listen-address=":9465"
  13. The listen address.
  14. --version Show application version.

Integration with Prometheus

Here is a Prometheus scrape_config snippet that configures Prometheus to scrape node_exporter assuming that it is deployed on all your Scaleway servers.

  1. - job_name: node
  2. # Assuming that prometheus and prometheus-scw-sd are started from the same directory.
  3. file_sd_configs:
  4. - files: [ "./scw.json" ]
  5. # The relabeling does the following:
  6. # - overwrite the scrape address with the node_exporter's port.
  7. # - strip leading commas from the tags label.
  8. # - save the region label (par1/ams1).
  9. # - overwrite the instance label with the server's name.
  10. relabel_configs:
  11. - source_labels: [__meta_scaleway_private_ip]
  12. replacement: "${1}:9100"
  13. target_label: __address__
  14. - source_labels: [__meta_scaleway_tags]
  15. regex: ",(.+),"
  16. target_label: tags
  17. - source_labels: [__meta_scaleway_location_zone_id]
  18. target_label: region
  19. - source_labels: [__meta_scaleway_name]
  20. target_label: instance

The following meta labels are available on targets during relabeling:

  • __meta_scaleway_architecture: the architecture of the server.
  • __meta_scaleway_blade_id: the identifier of the blade (can be empty).
  • __meta_scaleway_chassis_id: the identifier of the chassis (can be empty).
  • __meta_scaleway_cluster_id: the identifier of the cluster (can be empty).
  • __meta_scaleway_commercial_type: the commercial type of the server (eg START1-XS).
  • __meta_scaleway_hypervisor_id: the identifier of the hypervisor.
  • __meta_scaleway_identifier: the identifier of the server.
  • __meta_scaleway_image_id: the identifier of the server’s image.
  • __meta_scaleway_image_name: the name of the server’s image.
  • __meta_scaleway_name: the name of the server.
  • __meta_scaleway_node_id: the identifier of the node.
  • __meta_scaleway_organization: the organization owning the server.
  • __meta_scaleway_platform_id: the identifier of the platform.
  • __meta_scaleway_private_ip: the private IP address of the server.
  • __meta_scaleway_public_ip: the public IP address of the server (can be empty).
  • __meta_scaleway_state: the state of the server.
  • __meta_scaleway_tags: comma-separated list of tags associated to the server (trailing commas on both sides).
  • __meta_scaleway_zone_id: the identifier of the zone (region).

Contributing

PRs and issues are welcome.

License

Apache License 2.0, see LICENSE.