Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] /find 400 Bad Request when % is first character in metric name #803

Open
brobotic opened this issue Oct 3, 2023 · 0 comments
Open
Labels

Comments

@brobotic
Copy link

brobotic commented Oct 3, 2023

Describe the bug
/find appears to return HTTP 400 Bad Request when a metric name starts with %.

The metrics /render okay in Grafana after the HTTP 400, but I'm hesitant to roll this out to end-users since it shows a red error pop-up "Bad Request".

Example queries:
E4_Environment.*.Processor._Total.%_User_Time.wsp
Environment.SERVER123.Processor._Total.%_User_Time.wsp

/find will succeed for each part of the metric until %_User_Time.wsp

username@carbonapi:/whisper$ curl http://127.0.0.1/metrics/find/?query=Environment.*.Processor.*
[{"allowChildren":1,"expandable":1,"leaf":0,"id":"Environment.*.Processor._Total","text":"_Total","context":{}}]

username@carbonapi:/whisper$ curl http://127.0.0.1/metrics/find/?query=Environment.*.Processor._Total.*
[{"allowChildren":0,"expandable":0,"leaf":1,"id":"Environment.*.Processor._Total.%_User_Time","text":"%_User_Time","context":{}}]

username@carbonapi:/whisper$ curl http://127.0.0.1/metrics/find/?query=Environment.*.Processor._Total.%_User_Time
missing parameter `query`

Could not reproduce issue after copying metric to the same path but without the %_ i.e. User_Time

CarbonAPI Version
Tried v0.16.1-1-g3eb7 and v0.16.1

CarbonAPI Configuration:

Error occurred with and without:

unicodeRangeTables:
  - "all"
listen: ":8080"
concurrencyLimit: 0
cache:
  type: "null"
  size_mb: 0
  defaultTimeoutSec: 60
cpus: 0
tz: ""
graphite:
  host: "graphite01:2013"
  interval: "60s"
  prefix: "carbon.api"
  pattern: "{prefix}.{fqdn}"
keepAliveInterval: "30s"
pidFile: ""
upstreams:
  buckets: 10
  timeouts:
    find: "60s"
    render: "60s"
    connect: "200ms"
  maxIdleConnsPerHost: 100
  graphite09compat: false
  backendsv2:
    backends:
      -
        groupName: "cluster1"
        protocol: "auto"
        maxBatchSize: 1000
        maxTries: 3
        lbMethod: "broadcast"
        servers:
          - "http://graphite11:8080"
          - "http://graphite12:8080"
          - "http://graphite13:8080"
          - "http://graphite14:8080"
      -
        groupName: "cluster2"
        protocol: "auto"
        maxBatchSize: 1000
        maxTries: 3
        lbMethod: "broadcast"
        servers:
          - "http://graphite21:8080"
          - "http://graphite22:8080"
          - "http://graphite23:8080"
          - "http://graphite24:8080"
expireDelaySec: 10
notFoundStatusCode: 200

unicodeRangeTables:
  - "all"

headersToLog:
  - "X-Panel-Id"
  - "X-Dashboard-Id"
  - "X-Real-Ip"
  - "X-Webauth-User"
logger:
  - logger: ""
    file: "stderr"
    level: "warn"
    encoding: "console"
    encodingTime: "iso8601"
    encodingDuration: "seconds"
  - logger: ""
    file: "/var/log/carbonapi/carbonapi.log"
    level: "info"
    encoding: "json"

Backend response (if possible)
Here is the logs from both carbonapi + the go-carbon 0.17.1 backend:

Date	Host	url	@data.url	http_code	@data.http_code	reason	@data.reason	query	Message	
2023-10-10T14:42:20.755Z	"go-carbon03"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor._Total.%_User_Time"]	find success	
2023-10-10T14:42:20.753Z	"carbonapi01"		"/render"		200				request served	
2023-10-10T14:42:20.753Z	"go-carbon05"	"/render/?format=carbonapi_v3_pb"		404		"no metrics found"			fetch failed	
2023-10-10T14:42:20.751Z	"go-carbon04"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor._Total.%_User_Time"]	find success	
2023-10-10T14:42:20.750Z	"carbonapi01"								find request failed when resolving globs	
2023-10-10T14:42:20.750Z	"go-carbon05"	"/metrics/find/?format=carbonapi_v3_pb"		404		"Not Found"		["Environment.*.Processor._Total.%_User_Time"]	find failed	
2023-10-10T14:42:20.749Z	"carbonapi01"								find request failed when resolving globs	
2023-10-10T14:42:20.749Z	"go-carbon02"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor._Total.%_User_Time"]	find success	
2023-10-10T14:42:20.696Z	"carbonapi01"		"/metrics/find"		400		"missing parameter `query`"		request failed	
2023-10-10T14:42:20.661Z	"go-carbon03"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor._Total"]	find success	
2023-10-10T14:42:20.657Z	"carbonapi01"		"/metrics/find"		200				request served	
2023-10-10T14:42:20.656Z	"go-carbon04"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor._Total"]	find success	
2023-10-10T14:42:20.654Z	"go-carbon05"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor._Total"]	find success	
2023-10-10T14:42:20.654Z	"go-carbon02"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor._Total"]	find success	
2023-10-10T14:42:20.616Z	"go-carbon03"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor"]	find success	
2023-10-10T14:42:20.613Z	"carbonapi01"		"/metrics/find"		200				request served	
2023-10-10T14:42:20.612Z	"go-carbon04"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor"]	find success	
2023-10-10T14:42:20.611Z	"go-carbon02"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor"]	find success	
2023-10-10T14:42:20.610Z	"go-carbon05"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*.Processor"]	find success	
2023-10-10T14:42:20.573Z	"go-carbon03"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*"]	find success	
2023-10-10T14:42:20.570Z	"carbonapi01"		"/metrics/find"		200				request served	
2023-10-10T14:42:20.569Z	"go-carbon04"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*"]	find success	
2023-10-10T14:42:20.568Z	"go-carbon05"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*"]	find success	
2023-10-10T14:42:20.568Z	"go-carbon02"	"/metrics/find/?format=carbonapi_v3_pb"		200				["Environment.*"]	find success	

Please let me know if I can provide any additional information. Thank you!

@brobotic brobotic added the bug label Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant