Skip to content

Add label field support for sub-queries #43

Closed
@skyairmj

Description

@skyairmj

Hi,

Prometheus-Sql is very helpful, especially the sub-metrics approach. However, sub-metrics doesn't support label fields yet. It makes prometheus-sql not be able to handle multi-row multi-metric scenarios.

Giving a query string as:

select group, subgroup, count, avg from test_table

and the result set as bellow:

group subgroup count avg
a a1 10 5
b b1 7 6

We'd like to register metrics as bellow:

metric value
xxx_count(group = 'a', subgroup='a1') 10
xxx_avg(group = 'a', subgroup='a1') 5
xxx_count(group = 'b', subgroup='b1') 7
xxx_avg(group = 'b', subgroup='b1') 6

To achieve this, shall we treat all fields not specified under sub-metrics as label fields for all sub metrics? e.g.

- xxx:
    sql: >
        select group, subgroup, count, avg from test_table
    sub-metrics: # group, subgroup become label fields for both xxx_count and xxx_avg metrics as above
      count: count
      avg: avg
    interval: 30s

What's your opinion?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions