Commit Graph

145 Commits

Author SHA1 Message Date
Frederic Branczyk 84d61f9a93
Introduce sharding 2019-08-30 13:51:30 +02:00
Tariq Ibrahim 51def15afa
use MustRegister instead of Register 2019-08-29 13:53:10 -07:00
Lili Cosic 177916445a Address PR comments 2019-08-29 10:21:07 +02:00
Lili Cosic 21b1f61285 *: Add list/watch success/error count total metrics
When kube-state-metrics does not have the correct roles to list or watch
 on a resource, it just logs this error but not actually error out. This
is a problem as the pod never restars and it is hard to catch any
problems as other resource metrics continue to be created correctly. We
only see this error in the noisy kube-state-metrics logs.

This registers two metrics `kube_state_metrics_watch_total` and
`kube_state_metrics_list_total`. With the following labels:
"result" label is the type of action count relates to, error or success.
"resource" label contains the resource <apiVersion.Kind>.

This way we can do a rate alert when kube-state-metrics error rate is
too high.

Example of the metrics:
kube_state_metrics_list_total{resource="*v1.Namespace",result="success"} 1
kube_state_metrics_list_total{resource="*v1.Node",result="error"} 52
kube_state_metrics_watch_total{resource="*v1beta1.Ingress",result="success"} 1
2019-08-28 13:29:07 +02:00
tariqibrahim 44319dbb0d vendor: remove unnecessary dependencies from the project. 2019-07-21 14:59:22 -07:00
Kubernetes Prow Robot 0ffcc30a0f
Merge pull request #791 from monzo/vertical-pod-autoscaler-metrics
store: add metrics for VerticalPodAutoscaler objects
2019-06-20 06:02:49 -07:00
Miles Bryant 67ef5ecc9c
store: add verticalpodautoscaler metrics 2019-06-20 12:24:37 +01:00
Kubernetes Prow Robot 3b1c7c268d
Merge pull request #773 from tariq1890/regex
feat: implement black/white- listing of metrics by regex
2019-06-19 06:48:32 -07:00
Tariq Ibrahim 2a3c696347
feat: implement black/white- listing of metrics by regex 2019-06-19 02:16:52 -07:00
Miles Bryant e1b45de7f6
builder/main: allow collectors not enabled by default
This fixes an issue where it was impossible to specify a collector that
was available but not selected by default.

Instead of checking whether chosen collectors are valid at flag parse
time, this moves the check into the builder, where we can reference it
against the availableStores in the builder. As a bonus, the error
message also prints out a list of available collectors:

```
kube-state-metrics --collectors non-existent-collector
I0618 15:23:34.517532   50719 main.go:88] Using collectors non-existent-collector
F0618 15:23:34.519132   50719 main.go:90] Error: collector non-existent-collector does not exist. Available collectors: persistentvolumeclaims,configmaps,limitranges,nodes,namespaces,persistentvolumes,pods,replicasets,services,cronjobs,deployments,ingresses,horizontalpodautoscalers,jobs,poddisruptionbudgets,secrets,certificatesigningrequests,daemonsets,endpoints,storageclasses,replicationcontrollers,resourcequotas,statefulsets
```
2019-06-18 16:28:11 +01:00
Lili Cosic 68aea02d26 Makefile,internal/collector: Rename collector -> store
Since the removal of collector, this introduces both the concept of the
store and the resources instead of collectors that the user passes in.

The user facing logs and flags were not changed as that would be a
regression.
2019-06-11 16:18:53 +02:00
Lili Cosic cbb7762dc5 *: Remove collector package
collector package was an unnecessary wrapper. This replaces the
.Collect with a call to Store.WriteAll every time a collect is needed.
2019-06-11 16:18:52 +02:00
Tariq Ibrahim 9bcb1959a5
return standardized test for health endpoint 2019-05-24 09:51:04 -07:00
tariqibrahim d1c88bd26a use a more idiomatic way of handling error messages 2019-04-14 00:00:51 -07:00
tariqibrahim 169d841e41 update the prometheus_client_golang dependency to the latest version: v0.9.2 2019-03-28 13:13:01 -07:00
tariqibrahim 1d4c741f84 use klog instead of glog 2019-02-19 20:03:04 -08:00
tariqibrahim cd5711c8f4 use cancelable context instead of context.TODO() 2019-02-13 10:13:21 -08:00
tariqibrahim ab128fedf4 correct some typographical mistakes in kube-state-metrics 2019-02-02 21:55:12 -08:00
Lili Cosic 3498aa7e9e *: Move collectors pkg to internal directory
This makes the rest of the packages useful to be used in a standalone
library without importing the kube-state-metrics specific collectors.

* Rename collectors -> collector package

* Rename metrics -> metric package

* Add metricFamily mocking in tests to prevent cyclic dependency.
2019-01-23 10:51:30 +01:00
Andreas Kohn 509a0dbc33
Remove the obsolete metrics code
These stopped getting populated with 234d788a0d, and
cannot be restored easily.

Related-to: #623
2019-01-10 12:08:12 +01:00
Lv Jiawei 8872080fbe Clear TODO comment in builder.go (#5)
Clear comment --- "TODO : What if not ok?". Because the collector's name
has been checked in CollectorSet.Set function. It will exit if collector' name
is not in DefaultCollectors. As a result, all collectors in Build.enabledCollectors
will find its constructor function. So I think it doesn't exist "not ok" situation.

Signed-off-by: MIBc <lvjiawei@cmss.chinamobile.com>
2018-12-14 15:34:07 +08:00
Max Leonard Inden 7a4887ab9a
pkg/collectors: Refactor node collector 2018-11-29 15:43:49 +01:00
Max Leonard Inden 7ac0ab7410
pkg/builder: Make collector order deterministic
Instead of iterating a map of enabled collectors, iterate a sorted
slice to achieve determinism across scrapes.

Having a consistent order in the metrics output enables Proemetheus to
apply optimizations during metric parsing and ingestion.
2018-11-29 15:43:44 +01:00
Max Leonard Inden af714c7a66
pkg/whiteblacklist: Encapsulate white- blacklisting logic into pkg 2018-11-29 15:43:42 +01:00
Max Leonard Inden d1444f8061
pkg/metrics_store: Accept Writer instead of returning metrics on scrape 2018-11-29 15:43:40 +01:00
Max Leonard Inden 581c49d593
pkg/collectors: Reintroduce help text 2018-11-29 15:43:39 +01:00
Max Leonard Inden d44a8bc991
pkg/collectors: Renable white-/blacklisting
Reenable feature to filter the exposition of metric families by their
name. This is now done at startup time, thereby not slowing down the
critical path.
2018-11-29 15:43:36 +01:00
Max Leonard Inden 4cc7e9be49
pkg/options: Add flag to enable gzip encoding for responses
Dependent on the environment users might or might not want to encode the
responses of kube-state-metrics via gzip independent of the
`Accept-Header` that the client (Prometheus) sends.
2018-10-24 16:11:53 +02:00
Max Leonard Inden 234d788a0d
*: Optimize performance & resource utilization via custom metrics store
This patch introduces a custom client go store, MetricsStore. It is
updated by a corresponding reflector. Instead of generating the
Prometheus custom metrics on demand, metrics are generated on new
Kubernetes object arrival.

In addition this patch replaces most of the logic of the Prometheus
client_golang package by its optimized custom logic to render metrics in
text format.

Next to these main changes this patch also includes:

- Documentation/design: Add performance optimization proposal
- tests/e2e.sh: Ignore "no help text" warnings by promtool
- .travis.yml: Run tests in parallel
  As non of the Travis tests depend on each other, there is no reason to
  run them in sequence. Instead this patch makes them run in parallel.
2018-10-16 15:49:16 +02:00
Max Leonard Inden 183c7988fb
main_test.go: Introduce overarching benchmark test
This patch adds a simple go benchmark test, injecting Kubernetes objects
and simulating scrape requests. It uses the Kubernetes client-go fake
client. Alongside comes some refactoring of each collectors structure
using informer factories to be compatible with the fake client.

The patch lays the groundwork to make future performance optimizations
comparable with past versions.

How to run test:
`go test -race -bench  . -memprofile=mem.out -cpuprofile=cpu.out`
2018-08-17 11:52:02 +02:00
Frederic Branczyk c522d44f7b
Allow white- and black-listing metrics to be exposed 2018-07-23 17:36:11 +02:00
Andy Xie e025e06707 adjust client-go User-Agent 2018-06-25 17:02:24 +08:00
Andy Xie 3258e1ed58 prefer protobuf instead of just json format 2018-06-12 16:55:11 +08:00
Andy Xie 14ba135253 add generic pod resource request and limit 2018-05-17 13:20:53 +08:00
Andy Xie 63668e4aff add support for differenct auth provider 2018-05-06 11:24:10 +08:00
Andy Xie fef896fa62 refactor to toward kubernetes way 2018-04-27 22:23:12 +08:00
Andy Xie 5a45360de1 sanity check 2018-03-15 00:06:58 +08:00
Tomas Dohnalek 5c63f7a2e7
Fixed namespaceList type 2018-03-13 08:55:18 +01:00
Tomas Dohnalek 494d6c2fd1
Allow to specify multiple namespace. 2018-03-13 08:55:17 +01:00
k8s-ci-robot 7590d83b1e
Merge pull request #371 from metalmatze/master
Use Kubernete's own func that creates config by apiserver or kubeconfig
2018-03-07 18:06:56 -08:00
Matthias Loibl 054d9cbb51
Remove unnecessary flag safe guards 2018-03-07 17:20:25 +01:00
Andy Xie 4b6ee09141 add secret and configmap metrics 2018-03-01 11:41:50 +08:00
Matthias Loibl 3438df5cbe Use Kubernete's own func that creates config by apiserver or kubeconfig 2018-02-17 16:39:24 +01:00
Raphael Deem 7b01f09851 use glog instead of log 2018-01-19 10:22:56 -08:00
Raphael Deem ff22a84098 enable log in the prom http handler 2018-01-18 15:25:59 -08:00
Andy Xie c797923132 revert componentstatus 2018-01-05 21:18:23 +08:00
Andy Xie ffde60edbc add kube-state-metrics own metrics 2018-01-03 23:29:34 +08:00
jordigilh 3863ec73f2 Pluralized 'Endpoint' in collector output name in main to match convention 2017-12-22 11:53:53 -05:00
jordigilh bdb3f96897 Add Endpoint collector 2017-12-20 13:48:55 -05:00
Frederic Branczyk 472492606d
Allow setting host/ip to bind HTTP server to 2017-12-20 14:06:50 +01:00
zouyee 5452f06393 add componentstatus metrics 2017-12-04 20:57:19 +08:00
zouyee 4eb3169e3d add persistentvolume 2017-12-03 23:43:42 +08:00
Andy Xie c006df3259 code refactor 2017-12-03 10:55:53 +08:00
zouyee 96c73b5f7a add version cli 2017-12-03 10:23:53 +08:00
zouyee 1b6f355263 fix hpa nil error 2017-10-25 15:54:33 +08:00
Frederic Branczyk 0e96be106a Merge pull request #230 from joemiller/hpa-metrics
implement horizontal pod autoscaler (HPA) metrics
2017-10-23 16:41:13 +02:00
Andy Xie 19797a2830 bump kubernetes&&client-go&&api&&apimachinery to 1.8 2017-10-11 20:03:19 +08:00
joe miller 703eccf39f
implement horizontal pod autoscaler (HPA) metrics 2017-10-10 10:43:51 -07:00
Kazuki Suda 1b267801f7 Avoid a random result 2017-09-21 09:23:42 +09:00
Kazuki Suda aa0c701ed4 Improve a usage message for collectors flag
It makes a sentence clear and shows a default value.

```
      --collectors string                Comma-separated list of collectors to be enabled. Defaults to "services,persistentvolumeclaims,nodes,replicationcontrollers,statefulsets,replicasets,resourcequotas,jobs,namespaces,daemonsets,deployments,limitranges,pods,cronjobs"
```
2017-09-20 16:05:30 +09:00
chenguoyan01 bc0696696a display default logtostderr in help output 2017-09-16 21:22:30 +08:00
chenguoyan01 720d15bb86 set logtostderr true 2017-09-16 07:20:05 +08:00
chenguoyan01 5483d5ef1f add goflag to parse glog flags 2017-09-15 23:27:39 +08:00
Andy Xie 1ad96f6daf add pprof 2017-09-14 07:43:14 +08:00
zouyee 24fb41d5c3 add namespace metric and fix code component etc. 2017-08-22 20:08:14 +02:00
Andy Xie 47dfb48f7a add namespace cmd arg 2017-08-21 22:11:33 +08:00
Yecheng Fu b3d25efe6a Add PersistentVolumeClaim metrics.
Initially, it contains only one metric: `kube_persistentvolumeclaim_status_phase`.
2017-07-28 10:56:30 +00:00
Stijn De Haes fe6a64feba Added StatefulSet metrics 2017-06-18 20:47:43 +02:00
Andrew Davidoff 87c400c02a Pull request updates set 2
* Break out timing metrics from info into their own metrics
* Protect against a nil pointer dereference
* New repo/module structure
2017-05-08 13:50:11 -04:00
Andrew Davidoff 988a30d318 Expose Job and CronJob metrics 2017-05-08 13:43:53 -04:00
Frederic Branczyk 20df7080c4
*: move collectors to own package 2017-05-08 13:24:15 +02:00
Frederic Branczyk a844b25df8
fix service and limitrange rbac roles and fix order and naming 2017-05-03 14:53:01 +02:00
Frederic Branczyk 1cd6838845
add service info and label metrics 2017-04-28 16:48:57 +02:00
Frederic Branczyk 81ba59afd9
add pod and node label metrics 2017-04-28 16:22:55 +02:00
zouyee 776a66e0b4 add limit range 2017-03-28 13:00:04 +08:00
Dominik Schulz 09edb28ae8 Add ReplicationController metrics 2017-03-07 11:52:16 +01:00
Frederic Branczyk edd182ece0
add replicaset metrics 2017-02-02 14:29:58 +01:00
Frederic Branczyk efdfc9a331
allow choosing which collectors to run 2017-02-02 14:07:02 +01:00
Andrew Davidoff 7b6eb5ab81 client-go update and new Deployment metric
* Update to the newest tagged client-go release, v2.0.0-alpha.1
* Expose Deployment RollingUpdate Strategy MaxUnavailable
2017-01-27 04:56:43 +00:00
koudaiii 047b1e6d7e If --cluster-info is false, kubeconfig is valid 2017-01-11 16:32:49 +09:00
Ferran Rodenas ac716b14dc Fix loading kubeconfig file
* Don't set a default --kubeconfig flag value so NewDefaultClientConfigLoadingRules
will pick up the default locations

* Set an ExplicitPath using --kubeconfig flag value
2016-12-20 22:28:45 +01:00
slaws cc49cb4468 Add resource quotas metrics (#51) 2016-12-15 13:13:28 -08:00
Dominik Schulz 6622d0a6e6 Add DaemonSet metrics (#54) 2016-12-12 12:55:45 -08:00
Fabian Reinartz 07e4d4f5b0 Merge pull request #30 from brancz/clientgo15
use kubernetes informer framework
2016-10-18 13:49:52 +02:00
Frederic Branczyk 67bf6b9c09 don't panic when requesting help (#42) 2016-10-17 15:32:29 +02:00
Frederic Branczyk 9bbd1af70d
use kubernetes informer framework 2016-10-17 14:32:51 +02:00
Frederic Branczyk f689aa5f04
vendor: k8s.io/client-go/1.5 2016-10-17 13:32:20 +02:00
Fabian Reinartz 031eb8da34 Add Makefile (#25)
* Remove canonical import path

This either causes issues for the CI or people having the
repo checked out into the correct k8s.io/kube-state-metrics directory

.

* Add Makefile
2016-09-20 12:12:20 +02:00
Daniel Sachse 1cce9e63cc Added docker image and kubernetes files 2016-09-20 11:11:53 +02:00
Frederic Branczyk 6af709b410 switch to k8s.io/client-go as kubernetes client 2016-09-14 10:23:02 +02:00
Frederic Branczyk 9e32ecd2dc cleanup unused code 2016-09-13 11:19:35 +02:00
Fabian Reinartz 53ddc0e346 Rework node metrics
This commit reworks node metrics in the same manner as deployment
metrics.
The node states are broken out into one time series for each possible
conditional state. One constant metric holds textual meta information
about cluster nodes.
2016-09-07 10:31:28 +02:00
Frederic Branczyk ed505ccd41 Container restart metric (#9)
* Rework container restart metric

This commit reworks the container restart metric in the same manner as
deployment metrics. The format remains unchanged to the previous format
as in one metric per container via labels.

* Normalize expected string representation

To be able to compare strings easier when a failure occurs, remove empty
lines and trim whitespace for each line of the expected metrics string.
2016-09-07 10:20:31 +02:00
Fabian Reinartz b15680d96d Rework deployment metrics (#6)
* Update prometheus client vendoring

* Rework deployment metrics

This change extracts the deployment metrics into their own
deployment collector. The metrics are collected synchronously with
each scrape rather than every 10 seconds.

The `deployment` label replaces the `name` label to avoid name
collisions further up in the monitoring chain.
2016-09-01 15:58:22 -07:00
Sam Ghods 795d6c51e7 Create kube-state-metrics 2016-05-06 14:36:03 -07:00