resmoio / kubernetes-event-exporter

Export Kubernetes events to multiple destinations with routing and filtering
Apache License 2.0
753 stars 149 forks source link

feat: Support for fractional second #183

Open LHozzan opened 3 months ago

LHozzan commented 3 months ago

Hi there.

We have a big cluster (over 20 nodes) and when some changes is apply by the automation, many events occurring in very short time and it is hard to decide, which was origin order, because the exporter support only second precision.

This is example from my small test cluster: Example Here you can see 6 events, which occurred in same seconds, but I am not sure, that in this order.

In payload (in the field @timestamp) I really not see more, like seconds precision:

{
  "_index": "kube-events-2024.05.21",
  "_id": "ND0Lmo8B-_TuvUTcn6BT",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2024-05-21T07:26:44.000Z",
    "source": "",
    "component": "kustomize-controller",
    "count": "1",
    "kind": "Kustomization",
    "labels": "{\"kustomize_toolkit_fluxcd_io/name\":\"bootstrap\",\"kustomize_toolkit_fluxcd_io/namespace\":\"cs-bootstrap\"}",
    "message": "Reconciliation finished in 311.72836ms, next run in 30m0s",
    "name": "firewall",
    "namespace": "cs-bootstrap",
    "reason": "ReconciliationSucceeded",
    "type": "Normal"
  },
  "fields": {
    "@timestamp": [
      "2024-05-21T07:26:44.000Z"
    ]
  },
  "sort": [
    1716276404000
  ]
}

In bigger clusters in some hot situation events can occurring hundred of kubernetes events in very short time, which can be missordered due to only seconds precision (setting .GetTimestampISO8601).

I would like to kindly ask you to expand the exporter and support full precision. So, field @timestamp should looks like 2024-05-21T07:39:59.348738261Z (for example, setting can be GetTimestampISO8601_ns or something like this).