Fixes nodeexporter

This commit is contained in:
Nemo 2018-01-06 14:39:49 +05:30
parent 26d9357793
commit baf56f0edb
5 changed files with 32 additions and 17 deletions

View File

@ -24,13 +24,13 @@ module "docker" {
domain = "bb8.fun" domain = "bb8.fun"
} }
module "radicale" { module "radicale" {
source = "radicale" source = "radicale"
domain = "radicale.bb8.fun" domain = "radicale.bb8.fun"
} }
module "monitoring" { module "monitoring" {
source = "monitoring" source = "monitoring"
gf-security-admin-password = "${var.gf-security-admin-password}" gf-security-admin-password = "${var.gf-security-admin-password}"
domain = "bb8.fun"
} }

View File

@ -11,7 +11,12 @@ scrape_configs:
- job_name: "node" - job_name: "node"
scrape_interval: 5s scrape_interval: 5s
static_configs: static_configs:
- targets: ["node_exporter:9100"] - targets: ["nodeexporter:9100"]
- job_name: 'cadvisor'
scrape_interval: 5s
static_configs:
- targets: ['cadvisor:8080']
rule_files: rule_files:
- "alert.rules" - "alert.rules"

View File

@ -13,4 +13,3 @@ data "docker_registry_image" "prometheus" {
data "docker_registry_image" "nodeexporter" { data "docker_registry_image" "nodeexporter" {
name = "prom/node-exporter" name = "prom/node-exporter"
} }

View File

@ -4,13 +4,14 @@ resource docker_container "grafana" {
labels { labels {
# "traefik.frontend.auth.basic" = "${var.basic_auth}" # "traefik.frontend.auth.basic" = "${var.basic_auth}"
"traefik.port" = 3000 "traefik.port" = 3000
"traefik.enable" = "true" "traefik.enable" = "true"
"traefik.frontend.headers.SSLTemporaryRedirect" = "true" "traefik.frontend.headers.SSLTemporaryRedirect" = "true"
"traefik.frontend.headers.STSSeconds" = "2592000" "traefik.frontend.headers.STSSeconds" = "2592000"
"traefik.frontend.headers.STSIncludeSubdomains" = "false" "traefik.frontend.headers.STSIncludeSubdomains" = "false"
"traefik.frontend.headers.contentTypeNosniff" = "true" "traefik.frontend.headers.contentTypeNosniff" = "true"
"traefik.frontend.headers.browserXSSFilter" = "true" "traefik.frontend.headers.browserXSSFilter" = "true"
# "traefik.frontend.headers.customResponseHeaders" = "${var.xpoweredby}" # "traefik.frontend.headers.customResponseHeaders" = "${var.xpoweredby}"
# "traefik.frontend.headers.customFrameOptionsValue" = "${var.xfo_allow}" # "traefik.frontend.headers.customFrameOptionsValue" = "${var.xfo_allow}"
} }
@ -22,6 +23,11 @@ resource docker_container "grafana" {
links = ["prometheus"] links = ["prometheus"]
env = [
"GF_SECURITY_ADMIN_PASSWORD=${var.gf-security-admin-password}",
"GF_SERVER_ROOT_URL=https://grafana.${var.domain}",
]
restart = "unless-stopped" restart = "unless-stopped"
destroy_grace_seconds = 10 destroy_grace_seconds = 10
must_run = true must_run = true
@ -31,6 +37,9 @@ resource docker_container "prometheus" {
name = "prometheus" name = "prometheus"
image = "${docker_image.prometheus.latest}" image = "${docker_image.prometheus.latest}"
# prometheus:prometheus
user = "985:983"
command = ["--config.file=/etc/prometheus/prometheus.yml"] command = ["--config.file=/etc/prometheus/prometheus.yml"]
volumes { volumes {
@ -43,7 +52,7 @@ resource docker_container "prometheus" {
file = "/etc/prometheus/prometheus.yml" file = "/etc/prometheus/prometheus.yml"
} }
links = ["nodeexporter"] links = ["nodeexporter", "cadvisor"]
restart = "unless-stopped" restart = "unless-stopped"
destroy_grace_seconds = 10 destroy_grace_seconds = 10
@ -73,11 +82,10 @@ resource docker_container "nodeexporter" {
command = [ command = [
"--path.procfs=/host/proc", "--path.procfs=/host/proc",
"--path.sysfs=/host/sys", "--path.sysfs=/host/sys",
"--collector.filesystem.ignored-mount-points=\"^/(sys|proc|dev|host|etc)($$|/)\"" "--collector.filesystem.ignored-mount-points=\"^/(sys|proc|dev|host|etc)($$|/)\"",
] ]
restart = "unless-stopped" restart = "unless-stopped"
destroy_grace_seconds = 10 destroy_grace_seconds = 10
must_run = true must_run = true
} }

View File

@ -1,20 +1,23 @@
variable "gf-security-admin-password" { variable "gf-security-admin-password" {
type = "string" type = "string"
} }
# variable "email" { # variable "email" {
# type = "string" # type = "string"
# } # }
# variable "domain" { variable "domain" {
# type = "string" type = "string"
# } }
variable "alert-slack-username" { variable "alert-slack-username" {
default = "Prometheus" default = "Prometheus"
} }
variable "alert-slack-channel" { variable "alert-slack-channel" {
default = "#notifications" default = "#notifications"
} }
variable "alert-slack-incoming-webhook" { variable "alert-slack-incoming-webhook" {
default = "https://hooks.slack.com/whatever" default = "https://hooks.slack.com/whatever"
} }