Implement json encoder/decoder for regexp#15383
Conversation
Signed-off-by: Ben Ye <benye@amazon.com>
bboreham
left a comment
There was a problem hiding this comment.
Do we really want JSON to be inconsistent from YAML?
In YAML we just give the string; your PR has a sub-field regex:.
Also I am wondering why Config doesn't need anything extra to marshal JSON.
Signed-off-by: Ben Ye <benye@amazon.com>
|
@bboreham Thanks I fixed the implementation. Also added json tags. |
Signed-off-by: Ben Ye <benye@amazon.com>
|
FYI: this broke the draft implementation I had for #8511 |
This reverts commit 872e2db.
I also am running into a use case where I want to get back a relabel config through the API (a new API endpoint for analyzing relabeling steps in the UI), and the JSON encoding differing from the YAML field names is disruptive. I would have to un-camelcase the field names in the UI again to show the original names. Maybe translating existing well-known config field names into camelCase isn't the best thing to do here after all? @yeya24 How much would it hurt you (or Thanos) if this was changed back to the original field names in JSON output? |
This adds: * A `ScrapePoolConfig()` method to the scrape manager that allows getting the scrape config for a given pool. * An API endpoint at `/api/v1/targets/relabel_steps` that takes a pool name and a label set of a target and returns a detailed list of applied relabeling rules and their output for each step. * A "show relabeling" link/button for each target on the discovery page that shows the detailed flow of all relabeling rules (based on the API response) for that target. Note that this changes the JSON encoding of the relabeling rule config struct to output the original snake_case (instead of camelCase) field names, and before merging, we need to be sure that's ok :) See my comment about that at #15383 (comment) Fixes #17283 Signed-off-by: Julius Volz <julius.volz@gmail.com>
This adds: * A `ScrapePoolConfig()` method to the scrape manager that allows getting the scrape config for a given pool. * An API endpoint at `/api/v1/targets/relabel_steps` that takes a pool name and a label set of a target and returns a detailed list of applied relabeling rules and their output for each step. * A "show relabeling" link/button for each target on the discovery page that shows the detailed flow of all relabeling rules (based on the API response) for that target. Note that this changes the JSON encoding of the relabeling rule config struct to output the original snake_case (instead of camelCase) field names, and before merging, we need to be sure that's ok :) See my comment about that at #15383 (comment) Fixes #17283 Signed-off-by: Julius Volz <julius.volz@gmail.com>
This adds: * A `ScrapePoolConfig()` method to the scrape manager that allows getting the scrape config for a given pool. * An API endpoint at `/api/v1/targets/relabel_steps` that takes a pool name and a label set of a target and returns a detailed list of applied relabeling rules and their output for each step. * A "show relabeling" link/button for each target on the discovery page that shows the detailed flow of all relabeling rules (based on the API response) for that target. Note that this changes the JSON encoding of the relabeling rule config struct to output the original snake_case (instead of camelCase) field names, and before merging, we need to be sure that's ok :) See my comment about that at #15383 (comment) Fixes #17283 Signed-off-by: Julius Volz <julius.volz@gmail.com>
This reverts commit 872e2db.
There is a usecase in Thanos where we need to marshal
relabel.Configto JSON and store in Thanos metadata file. This PR implements the corresponding JSON encoding and decoding function forRegexp. Otherwise it causes panic.This should fix thanos-io/thanos#7844.