!coeAONBrWyDJnYMbMi:nixos.org

NixOS System Operations

552 Members
About system administration for running NixOS systems in production. Declaratively manage your operations. | Room recommendations: #networking:nixos.org148 Servers

Load older messages


SenderMessageTime
8 Dec 2024
@hexa:lossy.networkhexathe rules are just not as robust ans simple to test as promql00:49:26
@hexa:lossy.networkhexa
# lokitool rules lint ruler.yml 
ERRO[0000] unable parse rules file                       error="could not parse expression for alert 'PostgresqlCollationMismatch' in group 'postgresql': parse error at line 1, col 19: syntax error: unexpected IDENTIFIER" file=ruler.yml
lokitool: error: prepare operation unsuccessful, unable to parse rules files: file read error, try --help
00:50:15
@hexa:lossy.networkhexaI also love how builtins.toJSON puts everything on line 100:50:36
@hexa:lossy.networkhexabecause that is totally for the benefit of dealing with such an error00:50:46
@magic_rb:matrix.redalder.orgmagic_rbKind of wish there was a way to make toJSON spew out pretty printed json00:56:06
@hexa:lossy.networkhexathe loki module should provide an option to accept rules directly and lint them01:22:20
@hexa:lossy.networkhexa
{
  "groups": [
    {
      "name": "postgresql",
      "rules": [
        {
          "alert": "PostgresqlCollationMismatch",
          "annotations": {
            "summary": "PostgreSQL database on {{ $labels.machine }} reports database collations mismatches"
          },
          "expr": "sum by (machine) (counter_over_time({unit=\"postgresql.service\"} |~ \"REFRESH COLLATION VERSION\" [5m])) > 0\n",
          "for": "1m",
          "labels": {
            "severity": "warning"
          }
        }
      ]
    }
  ]
}
01:39:44
@hexa:lossy.networkhexa
ERRO[0000] unable parse rules file                       error="could not parse expression for alert 'PostgresqlCollationMismatch' in group 'postgresql': parse error at line 1, col 19: syntax error: unexpected IDENTIFIER" file=/tmp/rules.yml
01:39:48
@hexa:lossy.networkhexareally, line 1 again?01:39:52
@hexa:lossy.networkhexaalso line 1 when remarshalled to yaml01:40:37
@hexa:lossy.networkhexa
01:41:18
@hexa:lossy.networkhexa *
groups:
- name: postgresql
  rules:
  - alert: PostgresqlCollationMismatch
    annotations:
      summary: PostgreSQL database on {{ $labels.machine }} reports database collations
        mismatches
    expr: "sum by (machine) (counter_over_time({unit=\"postgresql.service\"} |~ \"\
      REFRESH COLLATION VERSION\" [5m])) > 0\n"
    for: 1m
    labels:
      severity: warning
01:41:23
@hexa:lossy.networkhexathat yaml is also the shit01:41:28
@hexa:lossy.networkhexaawwh gross01:42:15
@hexa:lossy.networkhexathe tmpfiles created symlink is just never updated01:42:22
@hexa:lossy.networkhexawhat the actual fuck01:42:27
@hexa:lossy.networkhexanix just fails at yaml01:43:25
@hexa:lossy.networkhexa * nix just fails hard at yaml01:43:32
@hexa:lossy.networkhexa(╯°□°)╯︵ ┻━┻01:43:42
@hexa:lossy.networkhexaso after fixing the expression and running the linter it reformats the file to01:45:17
@hexa:lossy.networkhexa
namespace: rules
groups:
    - name: postgresql
      rules:
        - alert: PostgresqlCollationMismatch
          expr: |-
            {unit="postgresql.service"} |~ "WARNING:  database \"[^\"]+\" has a collation version mismatch" | regexp "database \"(?<database>[^\"]+)\""
          for: 1m
          labels:
            severity: warning
          annotations:
            summary: PostgreSQL database on {{ $labels.machine }} reports database collations mismatches
01:45:28
@hexa:lossy.networkhexaand of course the loki module has a configFile escape02:31:49
@hexa:lossy.networkhexa
  yaml = pkgs.formats.yaml { };
  rulesFile = pkgs.runCommand "rules.yaml" {
    preferLocalBuild = true;
  } ''
    install -m0700 ${yaml.generate "rules.tmp" rulerConfig} $out
    ${lib.getExe' config.services.loki.package "lokitool"} rules lint $out
  '';
02:41:49
@hexa:lossy.networkhexaso perfectly linted every time02:43:40
@hexa:lossy.networkhexaand yet not alerts02:43:44
@hexa:lossy.networkhexafucking clownshow02:43:47
@hexa:lossy.networkhexaeven with debug logging no interesting ruler logs02:50:08
@hexa:lossy.networkhexaearlier today I added a dummy rule to test if alerting works at all19:34:23
@hexa:lossy.networkhexa
      name = "housekeeping";
      rules = [ {
        alert = "LokiAlwaysFiring";
        expr = "vector(1)";
        annotations.summary = "Rule that always fires to test alert propagation";
      } ];
19:34:46
@hexa:lossy.networkhexadoes not propagate 🤷19:34:59

Show newer messages


Back to Room ListRoom Version: 10