Commit Graph

96 Commits

Author SHA1 Message Date
Frederic Branczyk f3d41de450
Add auto detecting of sharding
main_test.go: Add model based test for sharding

In order to ensure a sharded system behaves equal to an unsharded
system, a model based test has been introduced. It scrapes an unsharded
setup and compares its output with the union of a sharded setup
therefore ensuring semantic equality.
2019-08-30 22:45:35 +02:00
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