[8.18] [OBX-UX-MGMT][BUG] Fix chart in Custom Threshold rule when the field name has slashes (#209263) (#209523)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[OBX-UX-MGMT][BUG] Fix chart in Custom Threshold rule when the field
name has slashes
(#209263)](https://github.com/elastic/kibana/pull/209263)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Faisal
Kanout","email":"faisal.kanout@elastic.co"},"sourceCommit":{"committedDate":"2025-02-04T12:18:27Z","message":"[OBX-UX-MGMT][BUG]
Fix chart in Custom Threshold rule when the field name has slashes
(#209263)\n\n## Summary\r\n\r\nIt fixes #201511\r\n\r\n<img
width=\"680\" alt=\"Screenshot 2025-02-03 at 12 51
56\"\r\nsrc=\"https://github.com/user-attachments/assets/fe3fa780-c50d-4906-8c5b-6758fea5fe9c\"\r\n/>\r\n\r\n###
Release notes:\r\nFix the preview chart in the Custom Threshold rule
creation form when\r\nthe field name has
slashes","sha":"ed333de757b67bfeb1e68ec33b64bb238ecc21eb","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Feature:Alerting","backport:prev-minor","backport:prev-major","Team:obs-ux-management","v9.1.0"],"title":"[OBX-UX-MGMT][BUG]
Fix chart in Custom Threshold rule when the field name has slashes
","number":209263,"url":"https://github.com/elastic/kibana/pull/209263","mergeCommit":{"message":"[OBX-UX-MGMT][BUG]
Fix chart in Custom Threshold rule when the field name has slashes
(#209263)\n\n## Summary\r\n\r\nIt fixes #201511\r\n\r\n<img
width=\"680\" alt=\"Screenshot 2025-02-03 at 12 51
56\"\r\nsrc=\"https://github.com/user-attachments/assets/fe3fa780-c50d-4906-8c5b-6758fea5fe9c\"\r\n/>\r\n\r\n###
Release notes:\r\nFix the preview chart in the Custom Threshold rule
creation form when\r\nthe field name has
slashes","sha":"ed333de757b67bfeb1e68ec33b64bb238ecc21eb"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/209263","number":209263,"mergeCommit":{"message":"[OBX-UX-MGMT][BUG]
Fix chart in Custom Threshold rule when the field name has slashes
(#209263)\n\n## Summary\r\n\r\nIt fixes #201511\r\n\r\n<img
width=\"680\" alt=\"Screenshot 2025-02-03 at 12 51
56\"\r\nsrc=\"https://github.com/user-attachments/assets/fe3fa780-c50d-4906-8c5b-6758fea5fe9c\"\r\n/>\r\n\r\n###
Release notes:\r\nFix the preview chart in the Custom Threshold rule
creation form when\r\nthe field name has
slashes","sha":"ed333de757b67bfeb1e68ec33b64bb238ecc21eb"}}]}]
BACKPORT-->

Co-authored-by: Faisal Kanout <faisal.kanout@elastic.co>
This commit is contained in:
Kibana Machine 2025-02-05 01:10:30 +11:00 committed by GitHub
parent ed5b521cb4
commit f6e739b19e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 25 deletions

View file

@ -19,8 +19,8 @@ const useCases = [
},
{
operation: 'sum',
operationWithField: 'sum(system.cpu.user.pct)',
sourceField: 'system.cpu.user.pct',
operationWithField: 'sum("system.cpu.user.pct")',
sourceField: '"system.cpu.user.pct"',
},
],
[
@ -32,8 +32,8 @@ const useCases = [
},
{
operation: 'max',
operationWithField: 'max(system.cpu.user.pct)',
sourceField: 'system.cpu.user.pct',
operationWithField: 'max("system.cpu.user.pct")',
sourceField: '"system.cpu.user.pct"',
},
],
[
@ -45,8 +45,8 @@ const useCases = [
},
{
operation: 'min',
operationWithField: 'min(system.cpu.user.pct)',
sourceField: 'system.cpu.user.pct',
operationWithField: 'min("system.cpu.user.pct")',
sourceField: '"system.cpu.user.pct"',
},
],
[
@ -58,8 +58,8 @@ const useCases = [
},
{
operation: 'average',
operationWithField: 'average(system.cpu.user.pct)',
sourceField: 'system.cpu.user.pct',
operationWithField: 'average("system.cpu.user.pct")',
sourceField: '"system.cpu.user.pct"',
},
],
[
@ -72,7 +72,7 @@ const useCases = [
{
operation: 'count',
operationWithField: `count(kql='system.cpu.user.pct: *')`,
sourceField: '',
sourceField: '""',
},
],
[
@ -85,7 +85,7 @@ const useCases = [
{
operation: 'count',
operationWithField: `count(kql='container.name:container\\'s name-1')`,
sourceField: '',
sourceField: '""',
},
],
[
@ -98,7 +98,7 @@ const useCases = [
{
operation: 'count',
operationWithField: `count(kql='host.name: host-*')`,
sourceField: '',
sourceField: '""',
},
],
[
@ -110,8 +110,21 @@ const useCases = [
},
{
operation: 'unique_count',
operationWithField: 'unique_count(system.cpu.user.pct)',
sourceField: 'system.cpu.user.pct',
operationWithField: 'unique_count("system.cpu.user.pct")',
sourceField: '"system.cpu.user.pct"',
},
],
[
{
aggType: Aggregators.CARDINALITY,
field: 'field.name/with/slashes',
filter: '',
name: '',
},
{
operation: 'unique_count',
operationWithField: 'unique_count("field.name/with/slashes")',
sourceField: '"field.name/with/slashes"',
},
],
[
@ -123,8 +136,8 @@ const useCases = [
},
{
operation: 'percentile',
operationWithField: 'percentile(system.cpu.user.pct, percentile=95)',
sourceField: 'system.cpu.user.pct',
operationWithField: 'percentile("system.cpu.user.pct", percentile=95)',
sourceField: '"system.cpu.user.pct"',
},
],
[
@ -136,8 +149,8 @@ const useCases = [
},
{
operation: 'percentile',
operationWithField: 'percentile(system.cpu.user.pct, percentile=99)',
sourceField: 'system.cpu.user.pct',
operationWithField: 'percentile("system.cpu.user.pct", percentile=99)',
sourceField: '"system.cpu.user.pct"',
},
],
[
@ -149,8 +162,8 @@ const useCases = [
},
{
operation: 'counter_rate',
operationWithField: `counter_rate(max(system.network.in.bytes), kql='')`,
sourceField: 'system.network.in.bytes',
operationWithField: `counter_rate(max("system.network.in.bytes"), kql='')`,
sourceField: '"system.network.in.bytes"',
},
],
[
@ -162,8 +175,8 @@ const useCases = [
},
{
operation: 'counter_rate',
operationWithField: `counter_rate(max(system.network.in.bytes), kql='host.name : "foo"')`,
sourceField: 'system.network.in.bytes',
operationWithField: `counter_rate(max("system.network.in.bytes"), kql='host.name : "foo"')`,
sourceField: '"system.network.in.bytes"',
},
],
];

View file

@ -23,8 +23,8 @@ export const getLensOperationFromRuleMetric = (metric: GenericMetric): LensOpera
if (aggType === Aggregators.RATE) {
return {
operation: 'counter_rate',
operationWithField: `counter_rate(max(${field}), kql='${escapedFilter}')`,
sourceField: field || '',
operationWithField: `counter_rate(max("${field}"), kql='${escapedFilter}')`,
sourceField: `"${field}"` || '',
};
}
@ -34,7 +34,7 @@ export const getLensOperationFromRuleMetric = (metric: GenericMetric): LensOpera
if (aggType === Aggregators.COUNT) operation = 'count';
if (field) {
operationArgs.push(field);
operationArgs.push(`"${field}"`);
}
if (aggType === Aggregators.P95) {
@ -49,7 +49,7 @@ export const getLensOperationFromRuleMetric = (metric: GenericMetric): LensOpera
return {
operation,
operationWithField: `${operation}(${operationArgs.join(', ')})`,
sourceField: field || '',
sourceField: `"${field}"` || '',
};
};