go-graphite / carbonapi

Implementation of graphite API (graphite-web) in golang
Other
309 stars 140 forks source link

[BUG] 400 Bad request when use special symbols in metrics ( [,=) #746

Open anch665 opened 1 year ago

anch665 commented 1 year ago

We have mongo metrics, they are displayed normally in graphite-web. We don't use Tags. but in carbonapi we get error

Bad Request: Bad Request Target : collectd.TEST.rtmtestnbohl03.27011[cluster=rs11,db=TECH_NBO2] Parsed so far : collectd.TEST.rtmtestnbohl03.mongo.27011[cluster Could not parse : =rs11,db=TECH_NBO2]
message:"Bad Request: Bad Request

Target              : collectd.TEST.rtmtestnbohl03.mongo.27011[cluster=rs11,db=TECH_NBO2]
Parsed so far       : collectd.TEST.rtmtestnbohl03.mongo.27011[cluster
Could not parse     : =rs11,db=TECH_NBO2]

exaple curl request port 8085 - grapite-web 1.1.10

port 8087 - carbonapi

[asg@rtmsasanalys01 ~]$ curl -v "http://rtmsasanalys01:8085/render?target=collectd.TEST.rtmtestnbohl03.mongo.*.gauge.repl.active_nodes&from=1670968724&until=1670990326&format=json&maxDataPoints=1968&format=json"
* About to connect() to rtmsasanalys01 port 8085 (#0)
*   Trying 10.72.63.49...
* Connected to rtmsasanalys01 (10.72.63.49) port 8085 (#0)
> GET /render?target=collectd.TEST.rtmtestnbohl03.mongo.*.gauge.repl.active_nodes&from=1670968724&until=1670990326&format=json&maxDataPoints=1968&format=json HTTP/1.1
> User-Agent: curl/7.29.0
> Host: rtmsasanalys01:8085
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.20.1
< Date: Wed, 14 Dec 2022 04:20:46 GMT
< Content-Type: application/json
< Content-Length: 70728
< Connection: keep-alive
< Vary: Accept-Encoding
< Expires: Wed, 14 Dec 2022 04:21:46 GMT
< Cache-Control: max-age=60
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, POST, OPTIONS
< Access-Control-Allow-Headers: origin, authorization, accept
< Access-Control-Allow-Credentials: true
<
[{"datapoints": [[3.0, 1670968740], [3.0, 1670968800], [3.0, 1670968860], [3.0, 1670968920], [3.0, 1670968980], [3.0, 1670969040], [3.0, 1670969100], [3.0, 1670969160], [3.0, 1670969220], [3.0, 1670969280], [3.0, 1670969340],

There is nothing in the log for this request.

[asg@rtmsasanalys01 ~]$ curl -v "http://rtmsasanalys01:8087/render?target=collectd.TEST.rtmtestnbohl03.mongo.*.gauge.repl.active_nodes&from=1670968724&until=1670990326&format=json&maxDataPoints=1968&format=json"
* About to connect() to rtmsasanalys01 port 8087 (#0)
*   Trying 10.72.63.49...
* Connected to rtmsasanalys01 (10.72.63.49) port 8087 (#0)
> GET /render?target=collectd.TEST.rtmtestnbohl03.mongo.*.gauge.repl.active_nodes&from=1670968724&until=1670990326&format=json&maxDataPoints=1968&format=json HTTP/1.1
> User-Agent: curl/7.29.0
> Host: rtmsasanalys01:8087
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Vary: Accept-Encoding
< X-Ctx-Carbonapi-Uuid: 3d0b9de0-8785-4523-8802-ef3f6f78f2cf
< Date: Wed, 14 Dec 2022 04:21:50 GMT
< Content-Length: 2
<
* Connection #0 to host rtmsasanalys01 left intact
Civil commented 1 year ago

Without a config that you've used it is impossible to tell if that's a misconfiguration or not.

https://github.com/go-graphite/carbonapi/blob/main/doc/configuration.md#unicoderangetables

There is an option that controls list of allowed symbols, and by default = is not one of them. Same about your other question in #747

anch665 commented 1 year ago
listen: "0.0.0.0:8087"

prefix: ""
expvar:
  enabled: true
  pprofEnabled: false
  listen:

headersToPass:
  - "X-Dashboard-Id"
  - "X-Grafana-Org-Id"
  - "X-Panel-Id"
headersToLog:
  - "X-Dashboard-Id"
  - "X-Grafana-Org-Id"
  - "X-Panel-Id"

define:
  -
    name: "perMinute"
    template: "perSecond({{.argString}})|scale(60)"

notFoundStatusCode: 404
# Max concurrent requests to CarbonZipper
concurency: 1000
cache:
   type: "mem"
   # Cache limit in megabytes
   size_mb: 0
   # Default cache timeout value. Identical to DEFAULT_CACHE_DURATION in graphite-web.
   defaultTimeoutSec: 60
   # Only used by memcache type of cache. List of memcache servers.
   memcachedServers:
       - "127.0.0.1:1234"
       - "127.0.0.2:1235"

cpus: 0
# Timezone, default - local
#tz: ""

maxBatchSize: 1000000
graphite:
    host: "localhost:2003"
    interval: "60s"
    prefix: "carbon.api"
    pattern: "{prefix}.{fqdn}"

idleConnections: 100
pidFile: ""

unicodeRangeTables:
   - "all"
#   - "Cyrillic"

upstreams:
    buckets: 100
upstreams:
    buckets: 100
    protocol: "carbonapi_v3_pb"
    timeouts:
       find: "20s"
       render: "20s"
       connect: "200ms"
    slowLogThreshold: "10s"
    concurrencyLimitPerServer: 0
    keepAliveInterval: "30s"
    maxIdleConnsPerHost: 10
    graphite09compat: false
    extractTagsFromArgs: true
    backends:
        - "http://localhost:8080"
expireDelaySec: 10