Commit Graph

89 Commits

Author SHA1 Message Date
Mikulas (Mike) Dite ba58b77bc8 Add shard_ordinal label
Facilitates many otherwise impossible promql queries
2021-01-18 14:52:04 +00:00
Mikulas (Mike) Dite 676c7a74d9 Expose sharding configuration via telemetry 2021-01-18 14:32:21 +00:00
Lili Cosic 0b76e7d4f4 internal/store: Rework label allow list for label metrics 2020-11-20 15:31:35 +01:00
Lili Cosic 9565e74e36 internal/store/certificatesigningrequest: Migrate to v1 2020-10-13 14:22:48 +02:00
Lili Cosic 9c1d4ace30 internal/store/ingress: Migrate to k8s.io/api/networking/v1 API 2020-10-13 10:19:11 +02:00
Lili Cosic 4093cb34de Adjust klog to klog/v2 2020-10-05 15:29:12 +02:00
Quentin Bisson 7250bc2b5c
Update go module path to k8s.io/kube-state-metrics/v2
Signed-off-by: Quentin Bisson <quentin@giantswarm.io>
2020-09-21 10:58:08 +02:00
Ben Ye 4d8d85f467 use promauto to register metrics
Signed-off-by: Ben Ye <yb532204897@gmail.com>
2020-09-13 19:07:47 -04:00
Joel Whittaker-Smith 908f87b2cd apply boundaries to metrics and allow via flag what labels to include
Signed-off-by: Joel Whittaker-Smith <jdws.dev@gmail.com>
2020-08-26 12:42:30 +02:00
root 1745b33e8e fix typos 2020-07-31 02:13:18 +00:00
qw1mb0 59e0e0cf05 switch mutatingwebhookconfiguration to v1 2020-05-16 20:41:16 +03:00
cedric lamoriniere dbbe062e36
fix internal.Builder to use buildStoreFunc 2020-04-13 20:28:37 +02:00
Alexander-Carpenter 71395e42c4 Fix build error 2020-02-05 20:14:30 -06:00
Alexander-Carpenter 69fe7da267 Rename collector to resource 2020-02-05 19:43:23 -06:00
Kubernetes Prow Robot 957e2b82e4
Merge pull request #1048 from tariq1890/merge1.9.4
Merge v1.9.4 into master
2020-02-05 02:19:55 -08:00
tariqibrahim 19527b425b fix: use the correct expectedType for networkPolicy reflector 2020-02-04 21:52:05 -08:00
Thibault Le Reste cb655340d6 Rename black-/whitelist to allow/deny-list 2020-02-03 17:05:11 +01:00
Michal Jura 7e6ee51012
internal/store/builder.go: Fix K8s API version 2020-01-31 08:34:05 +01:00
asidorovj f5729a5ccb add leases collector 2020-01-30 08:31:01 +03:00
cedric lamoriniere 369470d6ea builder.WithGenerateStoreFunc() is now mandatory
This commit introduces the fact that build.WithGenerateStoreFunc()
needs to be used for configuring properly the `Builder` (like any other
`With...` method.

* rename: `WithCustomGenerateStoreFunc` to `WithGenerateStoreFunc`.
* remove buildStorFunc defaulting in `NewBuilder()` function
* add `DefaultGenerateStoreFunc()` method in `BuilderInterface`
* update `Builder initialisation` in `main.go`

Signed-off-by: cedric lamoriniere <cedric.lamoriniere@datadoghq.com>
2020-01-08 13:45:05 +01:00
cedric lamoriniere 0a3c7d7fe3 create builder public package
* Allow to extend the internal Builder
* All logics still internal
* Add in `metric.Family` the metric family `Type` (counter, gauge)

Signed-off-by: cedric lamoriniere <cedric.lamoriniere@datadoghq.com>
2019-12-13 10:50:19 +01:00
cedric lamoriniere 72ad3cb412 Remove FamilyByteSlicer interface
- To allow other external Stores, remove the `FamilyByteSlicer` interface
  and give access directly to `metric.Family`.
- Move functions present in `pkg/metric/generator.go` to a dedicated package
  `generator` in `pkg/metric_generator/generator.go`.

Signed-off-by: cedric lamoriniere <cedric.lamoriniere@datadoghq.com>
2019-12-13 10:50:19 +01:00
cedric lamoriniere 494efc6fe5 [Builder] Allow custom Store generation func
- Use `cache.Store` interface for genericity and extensibility.
- Add `WithCustomGenerateStoreFunc` method to `Builder` struct for allowing
  custome metrics Stores generation.

Signed-off-by: cedric lamoriniere <cedric.lamoriniere@datadoghq.com>
2019-12-13 10:49:13 +01:00
Frederic Branczyk f4bbe71afc
store/builder.go: Use single MultiListerWatcher for single store
Previously kube-state-metrics created multiple ListerWatchers, with
multiple reflectors for a single store. This caused that on "replace"
events, the entire store was replaced with the content of a single
reflector instead of the union of all reflectors acting on a single
store.

This patch changes the architecture to have a single reflector that is
fed by a MultiListerWatcher acting on a single store, which as a result
fixes the replace actions.
2019-12-04 14:36:03 +01:00
Tariq Ibrahim ea4c2eb764
Merge branch 'master' into networkpolicy-collector 2019-10-17 10:10:45 -07:00
Miles Bryant e780fc34f3
store: export NetworkPolicy objects 2019-10-17 11:49:29 +01:00
Jens Erat 4e637854a2
add VolumeAttachment collector
Kubernetes has a new resource type: `VolumeAttachments`. They provide
helpful information on where a volume is attached and to alert on
unexpected attachment status (for example, differences between
information scraped from node-exporter and kube-state-metrics).

The collector adds a bunch of new metrics. Each VolumeAttachment (ie.,
each CSI-attached volume) will have one of each, so we do not overly
pollute the metrics space. Most metrics are rather unsurprising.

- `kube_volumeattachment_status_attachment_metadata`: provides a
  label-like export of the attachment metadata map. Generalizing the
  label-conversion function slightly helps at providing this metric.
- `kube_volumeattachment_created`: as VolumeAttachments are
  automatically created and we already suffered from duplicate
  `VolumeAttachments`, this can be invaluable for debugging
  misattachments.
- `kube_volumeattachment_spec_source_persistentvolume`: will only be
  generated when the volume source is of `PersistentVolume` type. The
  other type `inlineVolumeSpec` is still alpha-level and hard to map to
  metrics.

No end-to-end test manifest was added, as `VolumeAttachment`s are
automatically generated when mounting volumes.

Signed-off-by: Jens Erat <email@jenserat.de>
2019-10-13 21:36:50 +02:00
Nataly Sheinin 99623defbe
add mutatingwebhookconfiguration, validatingwebhookconfiguration metrics 2019-10-03 14:23:18 -04:00
YaoZengzeng d10e794282 remove unneeded blank line
Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
2019-09-17 10:54:04 +08:00
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
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
Tariq Ibrahim 1b42e7c450
lint: enforce goimports local prefixes 2019-08-20 10:33:05 -07:00
tariqibrahim 202710c5e0 *:use stable dependencies: robfig/cron/v3 and context 2019-07-21 13:41:24 -07:00
Tariq Ibrahim b42b29a605
Use the appsv1 apigroup when building the reflector for replicasets. 2019-07-10 11:24:56 -07:00
Miles Bryant 67ef5ecc9c
store: add verticalpodautoscaler metrics 2019-06-20 12:24:37 +01: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