Consul Recording Rules

24 views
Skip to first unread message

Jo

unread,
Aug 31, 2020, 10:20:18 PM8/31/20
to Prometheus Users
I see the below example for recording rules.

groups: 
   - name: example 
      rules: 
             - record: job:http_inprogress_requests:sum 
                expr: sum by (job) (http_inprogress_requests)

Our setup uses Consul for recording rules and I want to group recording rules. I tried the above example it doesn't work. If I supply an array of rules it works but If I supply an array of groups it doesn't work. Does anyone have a working example with Consul? 

Brian Candler

unread,
Sep 1, 2020, 5:05:52 AM9/1/20
to Prometheus Users
On Tuesday, 1 September 2020 03:20:18 UTC+1, Jo wrote:
If I supply an array of rules it works but If I supply an array of groups it doesn't work.

Please show the two configurations so we can compare them.  Also explain exactly what you mean by "it doesn't work".

Note that in the example you've posted, you have an array of groups *and* an array of rules (both arrays being of size 1)

Jo

unread,
Sep 1, 2020, 5:20:16 AM9/1/20
to Prometheus Users
Thanks Brian.

Taking the above example. If I supply below json:
{
   "groups": [
      {
         "name": "example",
         "rules": [
            {
               "record": "job:http_inprogress_requests:sum",
               "expr": "sum by (job) (http_inprogress_requests)"
            }
         ]
      }
   ]
}

Consul doesn't pick it up. While below just works fine.
[
            {
               "record": "job:http_inprogress_requests:sum",
               "expr": "sum by (job) (http_inprogress_requests)"
            }
         ]

Brian Candler

unread,
Sep 1, 2020, 5:27:40 AM9/1/20
to Prometheus Users
1. I don't know what you mean by "Consul doesn't pick it up".  Recording rules are nothing to do with service discovery.  Why are you expecting Consul to pick up this file?

2. Where exactly are you putting this JSON, and what is reading the JSON? For example, are you writing it to /foo/bar.json and your prometheus.yml has

rule_files:
  - "/foo/bar.json"

Or are we talking about something completely different?

Reply all
Reply to author
Forward
0 new messages