Prometheus Interactions¶
- promgen.prometheus.check_rules(rules)[source]¶
Use promtool to check to see if a rule is valid or not
The command name changed slightly from 1.x -> 2.x but this uses promtool to verify if the rules are correct or not. This can be bypassed by setting a dummy command such as /usr/bin/true that always returns true
- promgen.prometheus.import_rules_v2(config, content_object=None)[source]¶
Loop through a dictionary and add rules to the database
This assumes a dictionary in the 2.x rule format. See promgen/tests/examples/import.rule.yml for an example
- promgen.prometheus.render_rules(rules=None)[source]¶
Render rules in a format that Prometheus understands
- Parameters:
rules (list(Rule)) – List of rules
version (int) – Prometheus rule format (1 or 2)
- Returns:
Returns rules in yaml or Prometheus v1 format
- Return type:
bytes
This function can render in either v1 or v2 format We call prefetch_related_objects within this function to populate the other related objects that are mostly used for the sub lookups.