diff options
-rw-r--r-- | nix/hosts/corrino/configuration.nix | 2 | ||||
-rw-r--r-- | nix/hosts/corrino/www/grafana.emile.space.nix | 310 |
2 files changed, 165 insertions, 147 deletions
diff --git a/nix/hosts/corrino/configuration.nix b/nix/hosts/corrino/configuration.nix index 209bd2b..6e72dac 100644 --- a/nix/hosts/corrino/configuration.nix +++ b/nix/hosts/corrino/configuration.nix @@ -26,7 +26,7 @@ in { ./www/hydra.emile.space.nix # ./www/matrix.emile.space.nix ./www/netbox.emile.space.nix - # ./www/grafana.emile.space.nix + ./www/grafana.emile.space.nix ./www/photo.emile.space.nix # ./www/events.emile.space.nix ./www/tickets.emile.space.nix diff --git a/nix/hosts/corrino/www/grafana.emile.space.nix b/nix/hosts/corrino/www/grafana.emile.space.nix index d3e0e2f..7627ad2 100644 --- a/nix/hosts/corrino/www/grafana.emile.space.nix +++ b/nix/hosts/corrino/www/grafana.emile.space.nix @@ -35,11 +35,11 @@ in { editable = false; access = "proxy"; # server = "proxy", browser = "direct" } - { - name = "loki"; - url = "http://localhost:${toString config.services.loki.configuration.server.http_listen_port}"; - type = "loki"; - } + # { + # name = "loki"; + # url = "http://localhost:${toString config.services.loki.configuration.server.http_listen_port}"; + # type = "loki"; + # } ]; }; }; @@ -57,163 +57,181 @@ in { enabledCollectors = [ "systemd" ]; port = ports.prometheus_node_exporter; }; + systemd = { + enable = true; + port = ports.prometheus_systemd_exporter; + }; + smartctl = { + enable = true; + port = ports.prometheus_smartctl_exporter; + }; }; scrapeConfigs = [ { job_name = "corrino"; - static_configs = [{ - targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; - }]; + static_configs = [ + { targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; } + { targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.systemd.port}" ]; } + { targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.smartctl.port}" ]; } + ]; + } + { + job_name = "lampadas"; + static_configs = [ + { targets = [ "lampadas:9100" ]; } + { targets = [ "lampadas:9558" ]; } + { targets = [ "lampadas:9633" ]; } + ]; } ]; }; - loki = { - enable = true; - configuration = { - auth_enabled = false; - server = { - http_listen_port = ports.loki; - }; + # loki = { + # enable = true; + # configuration = { + # auth_enabled = false; + # server = { + # http_listen_port = ports.loki; + # }; - limits_config = { - reject_old_samples = true; - reject_old_samples_max_age = "7d"; - max_global_streams_per_user = 100000; - }; + # limits_config = { + # reject_old_samples = true; + # reject_old_samples_max_age = "7d"; + # max_global_streams_per_user = 100000; + # }; - common = { - instance_addr = "127.0.0.1"; - ring = { - instance_addr = "127.0.0.1"; - kvstore.store = "inmemory"; - }; - replication_factor = 1; - path_prefix = "/tmp/loki"; - }; + # common = { + # instance_addr = "127.0.0.1"; + # ring = { + # instance_addr = "127.0.0.1"; + # kvstore.store = "inmemory"; + # }; + # replication_factor = 1; + # path_prefix = "/tmp/loki"; + # }; - schema_config.configs = [{ - from = "2023-05-09"; - store = "boltdb-shipper"; - object_store = "filesystem"; - schema = "v11"; - index = { - prefix = "index_"; - period = "24h"; - }; - }]; - }; - }; + # schema_config.configs = [{ + # from = "2023-05-09"; + # store = "boltdb-shipper"; + # object_store = "filesystem"; + # schema = "v11"; + # index = { + # prefix = "index_"; + # period = "24h"; + # }; + # }]; + # }; + # }; }; - # allow the promtail user to read the nginx access files - users.users.promtail.extraGroups = [ "nginx" ]; + # # allow the promtail user to read the nginx access files + # users.users.promtail.extraGroups = [ "nginx" ]; - services = { - promtail = { - enable = true; - configuration = { - server = { - http_listen_port = ports.promtail; - grpc_listen_port = 0; - }; - positions.filename = "/tmp/positions.yml"; - clients = [{ - url = "http://localhost:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push"; - }]; - scrape_configs = [ + # services = { + # promtail = { + # enable = true; + # configuration = { + # server = { + # http_listen_port = ports.promtail; + # grpc_listen_port = 0; + # }; + # positions.filename = "/tmp/positions.yml"; + # clients = [{ + # url = "http://localhost:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push"; + # }]; + # scrape_configs = [ - # systemd - { - job_name = "journal"; - journal = { - max_age = "12h"; - labels = { - job = "systemd-journal"; - host = config.networking.hostName; - }; - }; - relabel_configs = [ - { - source_labels = [ "__journal__systemd_unit" ]; - target_label = "unit"; - } - ]; - } + # # systemd + # { + # job_name = "journal"; + # journal = { + # max_age = "12h"; + # labels = { + # job = "systemd-journal"; + # host = config.networking.hostName; + # }; + # }; + # relabel_configs = [ + # { + # source_labels = [ "__journal__systemd_unit" ]; + # target_label = "unit"; + # } + # ]; + # } - # nginx error log - { - job_name = "nginx-error-logs"; - static_configs = [{ - targets = [ "localhost" ]; - labels = { - job = "nginx-error-logs"; - host = "corrino"; - __path__ = "/var/log/nginx/*error.log"; - }; - }]; - } + # # nginx error log + # { + # job_name = "nginx-error-logs"; + # static_configs = [{ + # targets = [ "localhost" ]; + # labels = { + # job = "nginx-error-logs"; + # host = "corrino"; + # __path__ = "/var/log/nginx/*error.log"; + # }; + # }]; + # } - # nginx - { - job_name = "nginx"; - static_configs = [ - { - targets = [ "localhost" ]; - labels = { - job = "nginx"; - host = "corrino"; - __path__ = "/var/log/nginx/*access.log"; - }; - } - ]; - pipeline_stages = [ - # { - # regex = { - # expression = "(?:[0-9]{1,3}\.){3}([0-9]{1,3})"; - # replace = "***"; - # }; - # } - { - regex = { - expression = ''(?P<remote_addr>.+) - - \[(?P<time_local>.+)\] "(?P<method>.+) (?P<url>.+) (HTTP\/(?P<version>\d.\d))" (?P<status>\d{3}) (?P<body_bytes_sent>\d+) (["](?P<http_referer>(\-)|(.+))["]) (["](?P<http_user_agent>.+)["])''; - }; - } - { - labels = { - remote_addr = null; - time_local = null; - method = null; - url = null; - status = null; - body_bytes_sent = null; - http_referer = null; - http_user_agent = null; - }; - } - # { - # timestamp = { - # source = "time_local"; - # format = "02/Jan/2006:15:04:05 -0700"; - # }; - # } - { - drop = { - source = "url"; - expression = ''/(_matrix|.well-known|notifications|api|identity).*''; - }; - } - { - drop = { - source = "url"; - expression = ''grafana.*''; - }; - } - ]; - } + # # nginx + # { + # job_name = "nginx"; + # static_configs = [ + # { + # targets = [ "localhost" ]; + # labels = { + # job = "nginx"; + # host = "corrino"; + # __path__ = "/var/log/nginx/*access.log"; + # }; + # } + # ]; + # pipeline_stages = [ + # # { + # # regex = { + # # expression = "(?:[0-9]{1,3}\.){3}([0-9]{1,3})"; + # # replace = "***"; + # # }; + # # } + # { + # regex = { + # expression = ''(?P<remote_addr>.+) - - \[(?P<time_local>.+)\] "(?P<method>.+) (?P<url>.+) (HTTP\/(?P<version>\d.\d))" (?P<status>\d{3}) (?P<body_bytes_sent>\d+) (["](?P<http_referer>(\-)|(.+))["]) (["](?P<http_user_agent>.+)["])''; + # }; + # } + # { + # labels = { + # remote_addr = null; + # time_local = null; + # method = null; + # url = null; + # status = null; + # body_bytes_sent = null; + # http_referer = null; + # http_user_agent = null; + # }; + # } + # # { + # # timestamp = { + # # source = "time_local"; + # # format = "02/Jan/2006:15:04:05 -0700"; + # # }; + # # } + # { + # drop = { + # source = "url"; + # expression = ''/(_matrix|.well-known|notifications|api|identity).*''; + # }; + # } + # { + # drop = { + # source = "url"; + # expression = ''grafana.*''; + # }; + # } + # ]; + # } - ]; - }; - }; - }; + # ]; + # }; + # }; + # }; } |