undergreen / ansible-prometheus-node-exporter Goto Github PK
View Code? Open in Web Editor NEWAnsible role for deploying Prometheus node exporter
License: GNU General Public License v2.0
Ansible role for deploying Prometheus node exporter
License: GNU General Public License v2.0
Can you possibly make a new release? :) Or do you no longer maintain this role?
I freely admit that I know nothing of how galaxy works, but:
When I include this role via galaxy, or download it with ansible-galaxy install undergreen.prometheus-node-exporter, what I get in templates/init/prometheus-node-exporter.conf.j2 is:
[ec2-user@ip-172-31-76-131 init]$ cat prometheus-node-exporter.conf.j2
description "Prometheus Node Exporter"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [016]respawn
{% if upstart_version.stdout | replace("init (upstart ", "") |replace(")","") | version_compare('1.4', '>=') %}
setuid {{ prometheus_exporters_common_user }}
setgid {{ prometheus_exporters_common_group }}
{% endif %}script
exec >> "{{ prometheus_exporters_common_log_dir }}/node-exporter.log"
exec 2>&1
exec {{ prometheus_exporters_common_root_dir }}/node_exporter_current/node_exporter {% for prometheus_node_exporter_collector in prometheus_node_exporter_enabled_collectors %}--collector.{{ prometheus_node_exporter_collector }} {% endfor %} {% for flag, flag_value in prometheus_node_exporter_config_flags.items() %}--{{ flag }}={{ flag_value }} {% endfor %}end script
[ec2-user@ip-172-31-76-131 init]$
Which says that the version galaxy has does not include commit bc21fe2.
As a result, if i include this role via galaxy, node-exporter does not start on Amazon Linux.
I've just started to run the playbook in a machine with Ubuntu 16.04 and I get this error:
Source '/opt/prometheus/exporters/dist/node_exporter-0.12.0.linux-amd64.tar.gz' does not exist
Looking at the code, the problem seems to derive from the previous task, get_url, which doesn't specify the file name.
debug information:
ok: [localhost] => {
"changed": false,
"checksum_dest": "aea15b3d58b63527b164c9364005466b930b60a9",
"checksum_src": "aea15b3d58b63527b164c9364005466b930b60a9",
"dest": "/opt/prometheus/exporters/dist/be2fd42c-1320-11e6-8908-0b2ae94647e9",
"gid": 0,
"group": "root",
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"checksum": "",
"client_cert": null,
"client_key": null,
"content": null,
"delimiter": null,
"dest": "/opt/prometheus/exporters/dist",
"directory_mode": null,
"follow": false,
"force": false,
"force_basic_auth": false,
"group": null,
"headers": null,
"http_agent": "ansible-httpget",
"mode": null,
"owner": null,
"path": "/opt/prometheus/exporters/dist/be2fd42c-1320-11e6-8908-0b2ae94647e9",
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"sha256sum": "",
"src": null,
"timeout": 10,
"tmp_dest": null,
"unsafe_writes": null,
"url": "https://github.com/prometheus/node_exporter/releases/download/0.12.0/node_exporter-0.12.0.linux-amd64.tar.gz",
"url_password": null,
"url_username": null,
"use_proxy": true,
"validate_certs": true
}
},
"md5sum": "efe49b6fae4b1a5cb75b24a60a35e1fc",
"mode": "0644",
"msg": "OK (4021604 bytes)",
"owner": "root",
"size": 4021604,
"src": "/tmp/tmpmwjqus9l",
"state": "file",
"status_code": 200,
"uid": 0,
"url": "https://github.com/prometheus/node_exporter/releases/download/0.12.0/node_exporter-0.12.0.linux-amd64.tar.gz"
}
fatal: [localhost]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"content": null,
"creates": "/opt/prometheus/exporters/dist/node_exporter-0.12.0.linux-amd64/node_exporter",
"delimiter": null,
"dest": "/opt/prometheus/exporters/dist",
"directory_mode": null,
"exclude": [],
"extra_opts": [],
"follow": false,
"force": null,
"group": null,
"keep_newer": false,
"list_files": false,
"mode": null,
"original_basename": "node_exporter-0.12.0.linux-amd64.tar.gz",
"owner": null,
"regexp": null,
"remote_src": true,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": "/opt/prometheus/exporters/dist/node_exporter-0.12.0.linux-amd64.tar.gz",
"unsafe_writes": null,
"validate_certs": true
}
},
"msg": "Source '/opt/prometheus/exporters/dist/node_exporter-0.12.0.linux-amd64.tar.gz' does not exist"
}
I can make a PR with a change to the get_url task to specify the file name.
The default version is 0.12.0
and the lastest version available is 0.14.0
After deploying the Prometheus node exporter using this role, an empty directory (node_exporter-0.17.0.linux-amd64
in my case) is left in the home directory of the user used by ansible.
This directory shouldn't actually be created.
Hi,
Im receiving this random issue after upgrading. Any idea?
TASK [UnderGreen.prometheus-node-exporter : create systemd service unit] *******
Thursday 23 March 2017 16:58:03 +1300 (0:00:00.286) 0:01:10.353 ********
fatal: [images-worker]: FAILED! => {"changed": false, "failed": true, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'iteritems'"}
i changed the init file to the following. then it started again.
`description "Prometheus Node Exporter"
start on runlevel [2345]
respawn
setuid prometheus
setgid prometheus
script
exec >> "/var/log/prometheus/node-exporter.log"
exec 2>&1
exec /opt/prometheus/exporters/node_exporter_current/node_exporter --collector.conntrack --collector.cpu --collector.diskstats --collector.entropy --collector.filefd --collector.filesystem --collector.loadavg --collector.meminfo --collector.netdev --collector.netstat --collector.stat --collector.textfile --collector.time --collector.vmstat --collector.textfile.directory=/var/log/prometheus/textfile_collector --web.listen-address=0.0.0.0:9100 --log.level=info
end script
`
if you use upstart, or init.d it will cannot render the service file with python 3
Duplicate --
Actually the role support systemd & upstart service
it's will be good if it's also support the "old" sysvinit
The service reenable
handler is super generic. I ran into a conflict with another role, which arguably shouldn't be using that name either.
templates/etc/systemd/system/prometheus-node-exporter.service.j2
...
User=root
Group={{ prometheus_exporters_common_group }}
...
was that deliberate or just an oversight?
i tried it with
User={{ prometheus_exporters_common_user }}
Group={{ prometheus_exporters_common_group }}
and, so far, it works fine.
directory of URL have change for all version >= 0.13.0 :
2 example :
https://github.com/prometheus/node_exporter/releases/download/v0.14.0/node_exporter-0.14.0.linux-amd64.tar.gz
https://github.com/prometheus/node_exporter/releases/download/0.12.0/node_exporter-0.12.0.linux-amd64.tar.gz
The download task fails with this error:
TASK [UnderGreen.prometheus-node-exporter : download prometheus node exporter binary] *********************************************************************** task path: /home/ansible/roles/UnderGreen.prometheus-node-exporter/tasks/main.yml:3 fatal: [server]: FAILED! => { "msg": "An unhandled exception occurred while templating '{% if prometheus_node_exporter_version | version_compare('0.13.0', '>=') %}https://github.com/prometheus/node_exporter/releases/download/v{{ prometheus_node_exporter_version }}/{{ prometheus_node_exporter_release_name }}.tar.gz{% else %}https://github.com/prometheus/node_exporter/releases/download/{{ prometheus_node_exporter_version }}/{{ prometheus_node_exporter_release_name }}.tar.gz{% endif %}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: template error while templating string: no filter named 'version_compare'. String: {% if prometheus_node_exporter_version | version_compare('0.13.0', '>=') %}https://github.com/prometheus/node_exporter/releases/download/v{{ prometheus_node_exporter_version }}/{{ prometheus_node_exporter_release_name }}.tar.gz{% else %}https://github.com/prometheus/node_exporter/releases/download/{{ prometheus_node_exporter_version }}/{{ prometheus_node_exporter_release_name }}.tar.gz{% endif %}" }
Seems like version_compare
filter has been deprecated in Ansible 2.9
Recent versions support this feature:
--web.config="" [EXPERIMENTAL] Path to config yaml file that
can enable TLS or authentication.
While it's possible to use this role to configure that option, the value for it is a path, which also needs to be there.
It can be added manually, but that has to happen earlier. And if you want that config to be in the prometheus directory, you'd have to duplicate the directory creation logic.
I guess an optional task could be added to allow templating this file.
Role is not working with node_exporter >= 0.15.0
Due to prometheus/node_exporter#640 and prometheus/node_exporter#639 changes, templates that generate systemd/init/etc configuration files need to be updated to use new flags structure
Hi!
Is there any way to exclude gathering some metric from specific group?
For example use collector cpu, but not collecting one of its metrics.
when i run ansible with a script it will return the following error: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'stdout'"}
i think its issue is further described here:
https://www.middlewareinventory.com/blog/ansible-dict-object-has-no-attribute-stdout-or-stderr-how-to-resolve/
we fixed it the following way:
/etc/init/prometheus-node-exporter.conf depends on the output of a variable which is set in a previous task. But, in --check mode (dry run) this command is never executed and that rendering of this template fails. So, the fix is here to do not process this template when running in ansible_check_mode.
but maby you would like to fix it another way.
Version 1.5.0 is not available on Ansible Galaxy
With service manager upstart it fail to start the service via the handler :
RUNNING HANDLER [UnderGreen.prometheus-node-exporter : restart node exporter] ***********************************************
fatal: [XXXXX]: FAILED! => {"changed": false, "failed": true, "msg": "stop: Unknown job: prometheus-node-exporter\nstart: Unknown job: prometheus-node-exporter\n"}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.