Skip to content

stats: add bootstrap annotations for stats flush and eviction#3562

Merged
istio-testing merged 2 commits intoistio:masterfrom
kyessenov:stats_config
Sep 18, 2025
Merged

stats: add bootstrap annotations for stats flush and eviction#3562
istio-testing merged 2 commits intoistio:masterfrom
kyessenov:stats_config

Conversation

@kyessenov
Copy link
Copy Markdown
Contributor

Change-Id: I6c64ddd71aee82b570c7df25f13e2d710a046558

Change-Id: I6c64ddd71aee82b570c7df25f13e2d710a046558
Signed-off-by: Kuat Yessenov <kuat@google.com>
@kyessenov kyessenov requested a review from a team as a code owner September 4, 2025 21:00
@istio-policy-bot
Copy link
Copy Markdown

😊 Welcome @kyessenov! This is either your first contribution to the Istio api repo, or it's been
a while since you've been here.

You can learn more about the Istio working groups, Code of Conduct, and contribution guidelines
by referring to Contributing to Istio.

Thanks for contributing!

Courtesy of your friendly welcome wagon.

@istio-testing istio-testing added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 4, 2025

- name: sidecar.istio.io/statsFlushInterval
featureStatus: Alpha
description: Specifies the flush interval for push-based stat sinks, e.g. OTLP. Default interval is `5s`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

qq: if this is only for push-based stats sinks, what about prometheus (pull based)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Flush interval doesn't matter for prometheus. However, eviction piggy backs on flush timer, and eviction works for prometheus.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't get it. if it doesn't matter, but we evict when we flush, then it does matter...? And if the default is 5s, isn't that going to break prometheus?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Envoy always runs a stats flush timer, regardless of prometheus. During that timer, server stats are published (e.g. memory allocations, etc), and some other work is done, e.g. eviction.

Prometheus endpoint can snip stats are any point through, in between flushes.

So flush impacts prometheus only indirectly, e.g. by updating/removing some metrics.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe more concretely... I send 1 request to foo.com. I get an istio_request_total metric for it.

When, with prometheus, will this metric stop showing up in /stats/prometheus with/without this annotation set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For flush annotation: it will show up immediately and stay forever.
For eviction annotation: same, but it will disappear after 2*eviction interval unless the metric gets another hit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Sorry I was being a bit dense, github UI was hiding part of the PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@howardjohn @keithmattix can we move this forward?

@kyessenov kyessenov added the release-notes-none Indicates a PR that does not require release notes. label Sep 4, 2025
@kyessenov
Copy link
Copy Markdown
Contributor Author

/retest

@kyessenov kyessenov changed the title add bootstrap annotations stats: add bootstrap annotations for stats flush and eviction Sep 4, 2025
Copy link
Copy Markdown
Member

@zirain zirain left a comment

Choose a reason for hiding this comment

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

LGTM, Istio don't have first class API for bootstrap, this's the best option for now.

Change-Id: I245a8b8e70c54ecb4fd36a9d8fffdd0008bc78e9
Signed-off-by: Kuat Yessenov <kuat@google.com>
@kyessenov
Copy link
Copy Markdown
Contributor Author

@howardjohn @keithmattix How does this get moved forward?

resources:
- Pod

- name: sidecar.istio.io/statsFlushInterval
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the sidecar prefix mean this doesn't work for gateways/waypoints? I would guess no (that this is just convention) but wanted to confirm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, it's interpreted by pilot-agent which is the same for gateways and sidecars.

@istio-testing istio-testing merged commit 59f420b into istio:master Sep 18, 2025
5 checks passed
@ringerc
Copy link
Copy Markdown

ringerc commented Nov 28, 2025

Is there any way to control defaults for sidecar.istio.io/statsEvictionInterval settings via the Istio Telemetry resource, rather than having to annotate every single workload?

@zirain
Copy link
Copy Markdown
Member

zirain commented Nov 28, 2025

Is there any way to control defaults for sidecar.istio.io/statsEvictionInterval settings via the Istio Telemetry resource, rather than having to annotate every single workload?

this's part of bootstrap, which is not dynamiced.

@ringerc
Copy link
Copy Markdown

ringerc commented Dec 3, 2025

For others who want to adopt this Istio-cluster-wide, add it to your injectedAnnotations in your ConfigMap/istio-sidecar-injector in the (by default) istio-system namespace.

E.g.

apiVersion: v1
kind: ConfigMap
metadata:
  name: istio-sidecar-injector
  namespace: istio-system
  # ...
data:
  config: |-
    # ...
    injectedAnnotations:
      # The stats eviction interval should be long enough to preserve
      # continuity of samples over infrequent communications between
      # components, while avoiding infinite accumulation of series for
      # workloads that no longer exist.
      sidecar.istio.io/statsEvictionInterval: "15m"
      # We don't need the default 5s frequency in our stack, so flush every
      # 15s. Only affects push stats, and rounding for the eviction interval.      
      sidecar.istio.io/statsFlushInterval: "15s"

It'd be handy if https://istio.io/latest/docs/reference/config/annotations/ mentioned the default sidecar template; I'll see if I can cook up a docs patch for that.

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

Labels

release-notes-none Indicates a PR that does not require release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants