Skip to content

Logs updates to Kubernetes Objects for storing and querying with Loki

License

Notifications You must be signed in to change notification settings

grafana/kubernetes-diff-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1d4c302 · Mar 7, 2023

History

65 Commits
Jun 24, 2021
Jun 22, 2021
Jun 1, 2021
Mar 7, 2023
Aug 9, 2021
Oct 21, 2019
Jun 22, 2021
Oct 23, 2019
Jul 8, 2021
Oct 23, 2019
Mar 7, 2023
Mar 7, 2023
Jun 6, 2022
Jun 22, 2021

kubernetes-diff-logger

This simple application is designed to watch Kubernetes objects and log diffs when they occur. It is designed to log changes to Kubernetes objects in a clean way for storage and processing in Loki.

Example

./kubernetes-diff-logger -namespace=default
{"timestamp":"2019-10-23T16:57:23Z","verb":"updated","type":"deployment","notes":"[Replicas: 1 != 2]", "name":"nginx"}}
{"timestamp":"2019-10-23T16:57:35Z","verb":"updated","type":"deployment","notes":"[Template.Spec.Containers.slice[0].Image: nginx != nginx:latest]", "name":"nginx"}}

See Deployment for example yaml to deploy to Kubernetes. The example will monitor and log information about changes in all namespaces.

Usage

Usage of ./kubernetes-diff-logger:
  -config string
    	Path to config file.  Required.
  -kubeconfig string
    	Path to a kubeconfig. Only required if out-of-cluster.
  -log-added
    	Log when deployments are added.
  -log-deleted
    	Log when deployments are deleted.
  -master string
    	The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
  -namespace string
    	Filter updates by namespace.  Leave empty to watch all.
  -resync duration
    	Periodic interval in which to force resync objects. (default 30s)

Config File

differs:
- nameFilter: "*"
  type: "deployment"
- nameFilter: "*"
  type: "statefulset"
- nameFilter: "*"
  type: "daemonset"

About

Logs updates to Kubernetes Objects for storing and querying with Loki

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published