Skip to main content

Changes

When you save a config item to ConfigDB, it also tracks its changes. These changes may come from external sources like Kubernetes events or Azure activities. Alternatively, they can be automatically detected by comparing the old config with the newly changed one.

Types

Changes are of two types

  • Diff change
  • Event based change

Diff Change

These are changes generated by ConfigDB by simply comparing the old and new config values. The image below shows a change where the port value was modified from 8080 to 3000.

Kubernetes Deployment Replica change

Event based change

These are changes provided by an external source example: Kubernetes Events & AWS CLoudtrail. Event based changes have a type associated to it.

Event based config changes of a Kubernetes Pod

Change Transformation

You can transform a change before it's saved to the database.

FieldDescriptionSchemeRequiredTemplatable
mappingMapping is a list of CEL expressions that maps a change to the specified type[]ChangeMapping
excludeSelect what changes to exclude[]CELtrue

Exclusions

Some configs can have changes in high volume that may not be relevant. Example: A kubernetes Node config changes frequently as the pods in the cluster update their images. From the node's perspective the image changes are irrelevant.

This is where exclusions can become handy. Here's an example that ignore all image changes in a kubernetes node config:

kubernetes-scraper.yaml
apiVersion: configs.flanksource.com/v1
kind: ScrapeConfig
metadata:
name: kubernetes-scraper
spec:
kubernetes:
- clusterName: local-kind-cluster
transform:
changes:
exclude:
- 'config_type == "Kubernetes::Node" && details.message == "status.images"'

Template Variables

FieldDescriptionScheme
actionAction of the changedelete\|ignore
change_typeType of the changestring
config_typeType of the configstring
configThe corresponding json config of the changemap[string]any
created_atCreation time of the changetime.Time
created_byUser who created the changestring
detailsDetails of the change. Example: it could be a kubernetes event object.map[string]any
diffDiff of the changestring
external_change_idID of the change in the external systemstring
external_idID of the changestring
patchesPatches of the changestring
severitySeverity of the changestring
sourceSource of the changestring
summarySummary of the changestring

Mapping

When you encounter a diff change, unlike an event based change, it can sometimes appear cryptic. The summary of the change may not immediately indicate what the change is about. For example, the change 'status.images' might not be self-explanatory. To address this issue, we can assign types to these diff changes using mapping.

kubernetes-scraper.yaml
apiVersion: configs.flanksource.com/v1
kind: ScrapeConfig
metadata:
name: kubernetes-scraper
spec:
kubernetes:
- clusterName: local-kind-cluster
transform:
changes:
mapping:
- filter: >
change.change_type == 'diff' && change.summary == "status.containerStatuses" &&
patch != null && has(patch.status) && has(patch.status.containerStatuses) &&
patch.status.containerStatuses.size() > 0 &&
has(patch.status.containerStatuses[0].restartCount)
type: PodCrashLooping
- filter: >
change.change_type == 'diff' && change.summary == "status.images" && config.kind == "Node"
type: ImageUpdated
FieldDescriptionSchemeRequired
filterSelects changes to apply the mappingCELtrue
excludeType to be set on the changestringtrue

Template Variables

FieldDescriptionScheme
config_typeType of the configstring
configAccess the scraped configScrapedResult

Change Retention

Changes can quickly accumulate and grow large over time. While it's important to retain some changes, others can be discarded after a period. Retention enables you to discard changes based on their type.

Example: The scraper config below only retains one week of PullSuceeded changes.

kubernetes-scraper.yaml
apiVersion: configs.flanksource.com/v1
kind: ScrapeConfig
metadata:
name: kubernetes-scraper
spec:
retention:
changes:
- name: PullSuceeded
age: 7d # Only keep one week of PullSuceeded changes
kubernetes:
clusterName: local
FieldDescriptionSchemeRequired
nameName of the change typestringtrue
ageMaximum age of the change type to retain (12h, 30d)string
countMaximum count to retain the change typeint