From 73a61bf18ab361e6e91188673179b4c047fd4158 Mon Sep 17 00:00:00 2001 From: Petru Paler Date: Mon, 10 Jul 2023 06:36:41 +0100 Subject: [PATCH] Grafana config. --- services/grafana.hcl | 57 ++++++++++++++++++++++++++++++++++++++ storage/grafana-volume.hcl | 26 +++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 services/grafana.hcl create mode 100644 storage/grafana-volume.hcl diff --git a/services/grafana.hcl b/services/grafana.hcl new file mode 100644 index 0000000..6b23d05 --- /dev/null +++ b/services/grafana.hcl @@ -0,0 +1,57 @@ +job "grafana" { + datacenters = ["alo"] + + group "monitoring" { + network { + port "http" { + host_network = "tailscale" + } + } + + volume "data-volume" { + type = "csi" + source = "grafana-data" + access_mode = "single-node-writer" + attachment_mode = "file-system" + } + + task "grafana" { + driver = "docker" + + config { + image = "grafana/grafana-enterprise" + ports = [ "http" ] + } + + env { + GF_AUTH_BASIC_ENABLED = "false" + GF_SERVER_HTTP_PORT = "${NOMAD_PORT_http}" + } + + volume_mount { + volume = "data-volume" + destination = "/var/lib/grafana" + } + + service { + port = "http" + name = "grafana" + tags = [ + "traefik.enable=true", + "traefik.http.routers.grafana.entryPoints=websecure", + ] + check { + type = "http" + path = "/" + interval = "10s" + timeout = "2s" + } + } + + resources { + cpu = 100 + memory = 128 + } + } + } +} diff --git a/storage/grafana-volume.hcl b/storage/grafana-volume.hcl new file mode 100644 index 0000000..1a34425 --- /dev/null +++ b/storage/grafana-volume.hcl @@ -0,0 +1,26 @@ +id = "grafana-data" +name = "grafana-data" +type = "csi" +plugin_id = "seaweedfs" + +capacity_min = "10GiB" +capacity_max = "20GiB" + +capability { + access_mode = "single-node-writer" + attachment_mode = "file-system" +} + +# Optional: for 'nomad volume create', specify mount options to validate for +# 'attachment_mode = "file-system". Registering an existing volume will record +# but ignore these fields. +mount_options { + mount_flags = ["rw"] +} + +parameters { + # Available options: https://github.com/seaweedfs/seaweedfs-csi-driver/blob/master/pkg/driver/mounter_seaweedfs.go + collection = "appdata" + replication = "001" + path = "/appdata/grafana" +}