Commit Graph

62 Commits

Author SHA1 Message Date
Pranshu Srivastava eb80c09755
enhancement: add `livez` endpoint
Add a `livez` endpoint to identify network outages. This helps in
restarting the binary if such as case is observed.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2024-06-25 14:35:16 +05:30
pokom b4f032ecfd Add additional flags for IdleTimeouts 2024-06-06 13:11:00 -04:00
pokom e97933bcb9 fix(server): Add read and write timeouts
There are a few documented scenarios where `kube-state-metrics` will
lock up(#995, #1028). I believe a much simpler solution to ensure
`kube-state-metrics` doesn't lock up and require a restart to server
`/metrics` requests is to add default read and write timeouts and to
allow them to be configurable. At Grafana, we've experienced a few
scenarios where `kube-state-metrics` running in larger clusters falls
behind and starts getting scraped multiple times. When this occurs,
`kube-state-metrics` becomes completely unresponsive and requires a
reboot. This is somewhat easily reproduceable(I'll provide a script in
an issue) and causes other critical workloads(KEDA, VPA) to fail in
weird ways.

Adds two flags:
- `server-read-timeout`
- `server-write-timeout`

Updates the metrics http server to set the `ReadTimeout` and
`WriteTimeout` to the configured values.
2024-06-05 14:18:43 -04:00
Manuel Rüger fd2a1f83f3 chore: Build with go 1.22 2024-04-05 00:20:04 +02:00
Manuel Rüger 768a0a4338 chore: Bump prometheus/common library 2024-03-28 20:45:36 +01:00
Tetiana Kravchenko 393430ed86 fix the description of the 'kube_pod_container_status_last_terminated_timestamp' metric
Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
2024-03-04 11:40:34 +01:00
Tetiana Kravchenko 8876d40ecd add kube_pod_container_status_last_terminated_timestamp to the unit tests
Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
2024-01-22 15:36:58 +01:00
Kubernetes Prow Robot 4e431f6d14
Merge pull request #2234 from xonvanetta/feature/add-wilcard-allowlist-annotations
feat: Support filtering annotations allowlist by "*"
2023-11-09 18:26:07 +01:00
adinhodovic e9c7e66748 fix: Rename kube_pod_scheduler_name to kube_pod_scheduler 2023-11-07 09:56:05 +01:00
Fabian Heib e4d2bd48c8 Support filtering annotations allowlist by "*"
Resolves: add-wilcard-allowlist-annotations
2023-11-02 17:22:02 +01:00
adinhodovic c5c6c9a3f8 feat: Add new metric kube_pod_scheduler_name
Signed-off-by: adinhodovic <hodovicadin@gmail.com>
2023-10-19 19:41:34 +02:00
Kubernetes Prow Robot e8272ced47
Merge pull request #2145 from opeco17/feature/disable-labels-annotations-metrics-by-default
feat: disable labels and annotations metrics when metric-annotations-…
2023-08-22 06:34:54 -07:00
opeco17 6de105ebbe feat: disable labels and annotations metrics when metric-annotations-allowlist and metric-labels-allowlist are not provided 2023-08-14 14:38:23 +00:00
opeco17 3e4d91c4ba feat: implement kube_pod_status_initialized_time 2023-08-14 14:01:34 +00:00
Kubernetes Prow Robot 56a3a0a64e
Merge pull request #2096 from swarup-stripe/add-SA-to-kube-pod-info
feat: Adds new metric `kube_pod_service_account`
2023-07-26 03:54:18 -07:00
Manuel Rüger c3c552821a chore: Fix lint
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2023-07-13 10:35:24 +02:00
Swarup Srinivasan 8a8b7b47fc add new metric kube_pod_service_account 2023-06-13 11:19:01 -04:00
Pranshu Srivastava 25a1d8da05
Add support for variable VKs in CRS config
Add support for variable VKs in CRS config, while maintaining a cache
of discovered GVKs in the cluster, and updating it every 30s.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2023-05-20 01:26:02 +05:30
Manuel Rüger 1529d94ec8 feat: Use exporter-toolkit landingpage
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2023-03-17 19:15:05 +01:00
Manuel Rüger cef8c1fa4c feat!: Remove VerticalPodAutoscaler
BREAKING CHANGE: VPA is now supported only via Custom Resource Metrics

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2023-03-16 14:37:44 +01:00
Catherine Fang 4342ca7b97 Migrate all NewFamilyGenerator to NewFamilyGeneratorWithStability 2023-02-05 22:02:47 -05:00
Manuel Rüger fa5346405a Use structured logging 2023-01-27 17:35:26 +01:00
Manuel Rüger b41d5caa46 Enhance UserAgent with more information
Before:
"User-Agent: v2.7.0"

After:
"User-Agent: kube-state-metrics/v2.7.0 (linux/amd64) kubernetes/1cda0bf9"
2023-01-23 14:12:02 +01:00
Kubernetes Prow Robot 1cda0bf92e
Merge pull request #1938 from ryanrolds/rolds/pod_ready_time
Add metrics of kube_pod_status_ready_time and kube_pod_status_containers_ready_time redux
2023-01-19 05:28:35 -08:00
Kubernetes Prow Robot 63db4839e9
Merge pull request #1928 from mrueg/hotreloading-crs
Reload CustomResourceState Config File on Change
2023-01-12 06:16:54 -08:00
Ryan R. Olds 59b1728783 Merge branch 'main' into rolds/pod_ready_time 2023-01-10 16:26:17 -08:00
Lan Liang 4d8c58ad00 Support pod_ready_time and pod_container_ready_time
Co-authored-by: Szymon Grzemski <sz.grzemski@gmail.com>
Signed-off-by: Lan Liang <gcslyp@gmail.com>
2023-01-10 16:04:03 -08:00
Manuel Rüger 06268ab5ef Reload CustomResourceState Config File on Change
This change adds hot reloading support for the customresourcestate
config file.

It also resolves a bug in which the customresourcestate config file was
included in the ksm config file, in which it did not get detected.

It also resolves a bug in which customresourcestatemetrics were not
added when set resources were non-default resources.

Fixes: https://github.com/kubernetes/kube-state-metrics/issues/1892
2023-01-09 17:32:09 +01:00
frezes c3004c6145 Change kube_pod_status_qos_class to experimental metric
Signed-off-by: frezes <zhangjunhao@kubesphere.io>
2023-01-03 14:25:39 +08:00
frezes 288718a71f Add kube_pod_status_qos_class gauge to pod metrics
Signed-off-by: frezes <zhangjunhao@kubesphere.io>
2022-12-12 17:38:37 +08:00
Manuel Rüger eb3bdbcb58 Add metrics for CustomResourceConfig file 2022-12-08 09:39:17 +01:00
Kubernetes Prow Robot 143f94d579
Merge pull request #1916 from mrueg/config-change-metrics
Add metrics for config file changes
2022-12-07 01:10:38 -08:00
Paweł Kubica 2c3ea01cb2 Replace "<none>" with empty string for "owner_kind", "owner_name" and "owner_is_controller" dimensions.
Returning empty string instead of "<none>" value for "owner_kind", "owner_name" and "owner_is_controller" dimensions when no metadata.ownerReferences exists in Kubernetes resoures.
2022-12-03 15:17:02 +01:00
Manuel Rüger ee891760b8 Add metrics for config file changes
This uses code pieces from prometheus/alertmanager in https://github.com/prometheus/alertmanager/blob/main/config/coordinator.go#LL56C26-L56C26
licensed under Apache-2.0.

kube_state_metrics_config_hash{type="config", filename="config.yml"} 4.0061079457904e+13
kube_state_metrics_config_last_reload_success_timestamp_seconds{type="config", filename="config.yml"} 1.6697483049487052e+09
kube_state_metrics_config_last_reload_successful{type="config",
filename="config.yml"} 1

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2022-12-02 15:41:57 +01:00
Pranshu Srivastava 9860f46776
Implement hot-reloading based on config changes
Reload KSM on-the-fly when a change is detected in the configuration.

Meta changes (will squash)
2022-11-16 20:26:12 +05:30
Manuel Rüger d39f1b138b go.mod: Bump exporter-toolkit to 0.8.1
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2022-11-10 08:00:52 +01:00
Kubernetes Prow Robot c0a03ad6bb
Merge pull request #1813 from bavarianbidi/crd_only_mode
introduce custom-resources-only flag ...
2022-11-08 03:44:20 -08:00
Mario Constanti 53af11625c introduce custom-resources-only flag ...
... to only monitor all known custom-resource configurations instead of
listing each of them explicitly

Signed-off-by: Mario Constanti <mario@constanti.de>
2022-11-07 07:31:41 +01:00
Catherine Fang 43c6073234 Refactoring 2022-11-04 15:07:37 -04:00
Catherine Fang f9d29ba761 Refactoring 2022-11-04 08:44:00 -04:00
Catherine Fang d523f8e0e4 Move merging fieldselectors into app/server.go and replace namespaceFitler with fieldSelectorFilter 2022-11-04 08:44:00 -04:00
Catherine Fang 87a7793c7f Clean 2022-11-04 08:44:00 -04:00
Catherine Fang 2c0c8d2e51 Sharding per node 2022-11-04 08:44:00 -04:00
Pranshu Srivastava 5d20fd3454
Recommend kube-scheduler alternatives
Recommend metrics exposed by the kube-scheduler, in case of the ones below:
* `kube_pod_container_resource_limits`
* `kube_pod_container_resource_requests`

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2022-11-03 23:46:20 +05:30
Kubernetes Prow Robot 0d55500068
Merge pull request #1826 from rexagod/1786
Handle singular labels in allowlist
2022-10-21 09:27:51 -07:00
Manuel Rüger 6b7027ff41 Harden and add gosec linter
Remediate:
G104: Errors unhandled.
G109: Potential Integer overflow made by strconv.Atoi result conversion to int16/32
G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server
G304: Potential file inclusion via variable
G601: Implicit memory aliasing in for loop.

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2022-10-20 20:44:46 +02:00
Catherine Fang 5995c1e2cf Add all stable metrics 2022-10-14 08:25:39 -04:00
Pranshu Srivastava 052f572ae7
Handle singular labels in allowlist
Handle singular labels in allowlist failing when such a label is
supplied, in order to keep the behaviour in sync with --resources.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2022-09-26 12:17:32 +05:30
Shaun Sabo ffb6fe77e8 remove reason from exitcode 2022-08-24 12:55:27 -07:00
Shaun Sabo 085935314b unit tests 2022-08-24 12:55:27 -07:00