diff --git a/prometheus/tasks/main.yml b/prometheus/tasks/main.yml index 9dc7bfa..375d12c 100644 --- a/prometheus/tasks/main.yml +++ b/prometheus/tasks/main.yml @@ -37,7 +37,7 @@ when: ansible_service_mgr != 'systemd' - name: Install the prometheus server systemd unit - copy: src=prometheus.systemd dest=/etc/systemd/system/prometheus.service mode=0644 owner=root group=root + template: src=prometheus.systemd dest=/etc/systemd/system/prometheus.service mode=0644 owner=root group=root when: ansible_service_mgr == 'systemd' notify: systemd reload diff --git a/prometheus/templates/prometheus.default.j2 b/prometheus/templates/prometheus.default.j2 index 23fe266..f213f81 100644 --- a/prometheus/templates/prometheus.default.j2 +++ b/prometheus/templates/prometheus.default.j2 @@ -5,5 +5,5 @@ PROMETHEUS_DATADIR={{ prometheus_home }}/data PROMETHEUS_LOGLEVEL={{ prometheus_loglevel }} PROMETHEUS_CONF={{ prometheus_confdir }}/prometheus.yml PROMETHEUS_OPTS="{{ prometheus_opts }}" - +PROMETHEUS_STARTUP_OPTS="--config.file={{ prometheus_confdir }}/prometheus.yml --storage.tsdb.path={{ prometheus_home }}/data {{ prometheus_opts }} --log.level={{ prometheus_loglevel }}" diff --git a/prometheus/files/prometheus.systemd b/prometheus/templates/prometheus.systemd similarity index 67% rename from prometheus/files/prometheus.systemd rename to prometheus/templates/prometheus.systemd index 52a1ca8..a31c49d 100644 --- a/prometheus/files/prometheus.systemd +++ b/prometheus/templates/prometheus.systemd @@ -8,7 +8,7 @@ Type=simple User={{ prometheus_user }} Group={{ prometheus_user }} EnvironmentFile=/etc/default/prometheus -ExecStart=${PROMETHEUS_CMD} --config.file=${PROMETHEUS_CONF} --storage.tsdb.path=${PROMETHEUS_DATADIR} --log.level=${PROMETHEUS_LOGLEVEL} ${PROMETHEUS_OPTS} +ExecStart={{ prometheus_cmd }} $PROMETHEUS_STARTUP_OPTS Restart=on-failure [Install] diff --git a/prometheus/templates/prometheus.yml.j2 b/prometheus/templates/prometheus.yml.j2 index 2cade5c..9a12e23 100644 --- a/prometheus/templates/prometheus.yml.j2 +++ b/prometheus/templates/prometheus.yml.j2 @@ -1,4 +1,3 @@ -# my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. @@ -26,13 +25,4 @@ scrape_configs: # scheme defaults to 'http'. static_configs: - - targets: ['localhost:9090'], 'localhost:9100'] - labels: - group: 'Prometheus Server' - - - job_name: 'node' - - static_configs: - - targets: [ 'localhost:9100'] - labels: - group: 'node' + - targets: ['localhost:9090']