ES|QL CLAMP function
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Serverless
Preview
Preview
Stack
Preview
9.3+
Preview since 9.3
Clamps values to a specified minimum and maximum range.
field- Numeric expression. If
null, the function returnsnull. min- The min value to clamp data into.
max-
The max value to clamp data into.
Limits (or clamps) the values of all samples to have a lower limit of min and an upper limit of max.
| field | min | max | result |
|---|---|---|---|
| boolean | boolean | boolean | boolean |
| date | date | date | date |
| double | double | double | double |
| double | integer | integer | double |
| double | long | long | double |
| double | unsigned_long | unsigned_long | double |
| integer | double | double | double |
| integer | integer | integer | integer |
| integer | long | long | long |
| integer | unsigned_long | unsigned_long | unsigned_long |
| ip | ip | ip | ip |
| keyword | keyword | keyword | keyword |
| long | double | double | double |
| long | integer | integer | long |
| long | long | long | long |
| long | unsigned_long | unsigned_long | unsigned_long |
| unsigned_long | double | double | double |
| unsigned_long | integer | integer | unsigned_long |
| unsigned_long | long | long | long |
| unsigned_long | unsigned_long | unsigned_long | unsigned_long |
| version | version | version | version |
TS k8s
| EVAL full_clamped_cost = clamp(network.cost, clamp_max(network.bytes_in, 5), network.bytes_in / 100)
| KEEP full_clamped_cost, @timestamp
| full_clamped_cost:double | @timestamp:datetime |
|---|---|
| 10.0 | 2024-05-10T00:18:33.000Z |
| 9.0 | 2024-05-10T00:04:49.000Z |
| 9.0 | 2024-05-10T00:15:51.000Z |
| 9.0 | 2024-05-10T00:17:12.000Z |
| 9.0 | 2024-05-10T00:20:46.000Z |