Skip to content

Conversation

@crespocarlos
Copy link
Contributor

Backport

This will backport the following commits from main to 9.2:

Questions ?

Please refer to the Backport tool documentation

…ting (elastic#246438)

## Summary

Basically what this elastic#245224 does,
but focusing only on the Infra plugin changes

`has_data` endpoint will run this when the setting is not set

```json
{
  "index": "remote_cluster:metrics-*,remote_cluster:metricbeat-*",
  "allow_no_indices": true,
  "terminate_after": 1,
  "ignore_unavailable": true,
  "body": {
    "size": 0,
    "query": {
      "bool": {}
    }
  }
}
```

and this when the setting is set

```json
params {
  "index": "remote_cluster:metrics-*,remote_cluster:metricbeat-*",
  "allow_no_indices": true,
  "terminate_after": 1,
  "ignore_unavailable": true,
  "body": {
    "size": 0,
    "query": {
      "bool": {
        "filter": [
          {
            "bool": {
              "must_not": [
                {
                  "terms": {
                    "_tier": [
                      "data_frozen"
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    }
  }
}
```

Other pages are affected by this change, but are not a source for the
frozen tier being hit because they don't run unbounded queries

- Infra Inventory UI
```json
params {
  "allow_no_indices": true,
  "ignore_unavailable": true,
  "index": "remote_cluster:metrics-*,remote_cluster:metricbeat-*",
  "body": {
    "size": 0,
    "query": {
      "bool": {
        "must": [
          {
            "bool": {
              "filter": [
                {
                  "bool": {
                    "filter": [
                      {
                        "bool": {
                          "filter": [
                            {
                              "term": {
                                "data_stream.dataset": "hostmetricsreceiver.otel"
                              }
                            }
                          ]
                        }
                      }
                    ]
                  }
                },
                {
                  "range": {
                    "@timestamp": {
                      "gte": 1765824423511,
                      "lte": 1765824723511,
                      "format": "epoch_millis"
                    }
                  }
                },
                {
                  "exists": {
                    "field": "host.name"
                  }
                }
              ]
            }
          }
        ],
        "filter": [
          {
            "bool": {
              "must_not": [
                {
                  "terms": {
                    "_tier": [
                      "data_frozen"
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    },
    "aggs": {
      "groupings": {
        "composite": {
          "size": 2000,
          "sources": [
            {
              "groupBy0": {
                "terms": {
                  "field": "host.name"
                }
              }
            }
          ]
        },
        "aggs": {
          "histogram": {
            "date_histogram": {
              "field": "@timestamp",
              "fixed_interval": "60s",
              "offset": "-57511ms",
              "extended_bounds": {
                "min": 1765824423511,
                "max": 1765824723511
              }
            },
            "aggregations": {
              "cpu_idle": {
                "terms": {
                  "field": "state",
                  "include": [
                    "idle",
                    "wait"
                  ]
                },
                "aggs": {
                  "avg": {
                    "avg": {
                      "field": "system.cpu.utilization"
                    }
                  }
                }
              },
              "cpu_idle_total": {
                "sum_bucket": {
                  "buckets_path": "cpu_idle.avg"
                }
              },
              "cpuV2": {
                "bucket_script": {
                  "buckets_path": {
                    "cpuIdleTotal": "cpu_idle_total"
                  },
                  "script": "1 - params.cpuIdleTotal",
                  "gap_policy": "skip"
                }
              },
              "__metadata__": {
                "top_metrics": {
                  "size": 1,
                  "metrics": [
                    {
                      "field": "host.name"
                    },
                    {
                      "field": "host.ip"
                    },
                    {
                      "field": "host.os.name"
                    },
                    {
                      "field": "cloud.provider"
                    }
                  ],
                  "sort": {
                    "@timestamp": "desc"
                  }
                }
              }
            }
          },
          "metricsets": {
            "terms": {
              "field": "metricset.name"
            }
          }
        }
      }
    }
  }
}
```
- Metrics Explorer

```json
{
  "allow_no_indices": true,
  "ignore_unavailable": true,
  "index": "remote_cluster:metrics-*,remote_cluster:metricbeat-*",
  "body": {
    "size": 0,
    "query": {
      "bool": {
        "must": [
          {
            "bool": {
              "filter": [
                null,
                {
                  "range": {
                    "@timestamp": {
                      "gte": 1765821298325,
                      "lte": 1765824898325,
                      "format": "epoch_millis"
                    }
                  }
                }
              ]
            }
          }
        ],
        "filter": [
          {
            "bool": {
              "must_not": [
                {
                  "terms": {
                    "_tier": [
                      "data_frozen"
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    },
    "aggs": {
      "histogram": {
        "date_histogram": {
          "field": "@timestamp",
          "fixed_interval": "30s",
          "offset": "0s",
          "extended_bounds": {
            "min": 1765821298325,
            "max": 1765824898325
          }
        },
        "aggregations": {
          "metric_0": {
            "avg": {
              "field": "system.cpu.total.norm.pct"
            }
          },
          "metric_1": {
            "avg": {
              "field": "kubernetes.pod.cpu.usage.node.pct"
            }
          },
          "metric_2": {
            "avg": {
              "field": "docker.cpu.total.pct"
            }
          }
        }
      },
      "metricsets": {
        "terms": {
          "field": "metricset.name"
        }
      }
    }
  }
}
```

---------

Co-authored-by: Nathan L Smith <nathan.smith@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Caue Marcondes <caue.marcondes@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Coen Warmer <coen.warmer@gmail.com>
(cherry picked from commit aedfb94)

# Conflicts:
#	x-pack/solutions/observability/plugins/metrics_data_access/moon.yml
#	x-pack/solutions/observability/plugins/metrics_data_access/tsconfig.json
Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crespocarlos crespocarlos merged commit 4fac838 into elastic:9.2 Dec 16, 2025
17 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
logsShared 338 339 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
infra 52.0KB 52.2KB +195.0B
logsShared 90.0KB 90.2KB +219.0B
total +414.0B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants