carbonapi icon indicating copy to clipboard operation
carbonapi copied to clipboard

[BUG] asPercent() function error when None is used as a total parameter

Open spoofedpacket opened this issue 4 years ago • 0 comments

Describe the bug Hi, following a migration to CarbonAPI from graphite-web, we encountered an issue with a particular asPercent() query:

asPercent(foo.*BAR*.baz.*.*, None, 1, 3)

It results in the following error:

Internal Server Error: function=asPercent: found wildcard where series expected

CarbonAPI Version v0.15.3

CarbonAPI Configuration:

backendCache:
  defaultTimeoutSec: 60
  size_mb: '1024'
  type: mem
cache:
  defaultTimeoutSec: 60
  size_mb: '1024'
  type: mem
concurency: 1000
cpus: '1'
expireDelaySec: 600
graphite:
  host: carbon:2003
  interval: 60s
  pattern: '{prefix}.{fqdn}'
  prefix: carbon.api
headersToLog:
- X-Dashboard-Id
- X-Grafana-Org-Id
- X-Panel-Id
headersToPass:
- X-Dashboard-Id
- X-Grafana-Org-Id
- X-Panel-Id
idleConnections: 1000
listen: 0.0.0.0:8081
logger:
- encoding: json
  encodingDuration: nanos
  encodingTime: iso8601
  file: stdout
  level: info
  logger: ""
maxBatchSize: 0
pidFile: ""
tz: ""
upstreams:
  backendsv2:
    backends:
    - groupName: graphite-clickhouse
      lbMethod: roundrobin
      maxTries: 3
      protocol: carbonapi_v2_pb
      servers:
      - http://graphite-clickhouse-0:9090
      - http://graphite-clickhouse-1:9090
      - http://graphite-clickhouse-2:9090
  buckets: 10
  concurrencyLimitPerServer: 1000
  keepAliveInterval: 30s
  maxIdleConnsPerHost: 1000
  timeouts:
    connect: 200ms
    find: 10s
    render: 30s

Simplified query (if applicable)

asPercent(foo.*BAR*.baz.*.*, None, 1, 3)

Additional context Backend: graphite-clickhouse 0.11.7 with clickhouse-server 20.3.17.17

Note: The query works as expected with graphite-web 1.1.8

The problem stems from the use of None as the total parameter in the query. In graphite-web, if the total parameter is None , then for each series in the seriesList the percentage of the sum of series in that group is returned:

https://github.com/graphite-project/graphite-web/blob/a89711135b0a0a3dfa72310188e2cd33914a6674/webapp/graphite/render/functions.py#L960

However it looks like this behaviour isn't present in carbonapi.

spoofedpacket avatar Nov 08 '21 15:11 spoofedpacket