Skip to content

Commit

Permalink
support comma-separated tag values (#2179)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuud committed Jan 6, 2023
1 parent 0ac7a6b commit b9dc801
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions spring-boot-admin-server-ui/src/main/frontend/services/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,24 @@ class Instance {
}

async fetchMetric(metric, tags) {
const params = tags ? {
tag: Object.entries(tags)
const params = new URLSearchParams();
if (tags) {
let firstElementDuplicated = false;
Object.entries(tags)
.filter(([, value]) => typeof value !== 'undefined' && value !== null)
.map(([name, value]) => `${name}:${value}`)
.join(',')
} : {};
.forEach(([name, value]) => {
params.append('tag', `${name}:${value}`);

if (!firstElementDuplicated) {
// workaround for tags that contains comma
// take a look at https://github.com/spring-projects/spring-framework/issues/23820#issuecomment-543087878
// If there is single tag specified and name or value contains comma then it will be incorrectly split into several parts
// To bypass it we duplicate first tag.
params.append('tag', `${name}:${value}`);
firstElementDuplicated = true;
}
})
}
return this.axios.get(uri`actuator/metrics/${metric}`, {
params
});
Expand Down

0 comments on commit b9dc801

Please sign in to comment.