Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using globs for enum processor #7184

Closed
M0rdecay opened this issue Mar 17, 2020 · 0 comments · Fixed by #8598
Closed

Allow using globs for enum processor #7184

M0rdecay opened this issue Mar 17, 2020 · 0 comments · Fixed by #8598
Assignees
Labels
feature request Requests for new plugin and for new features to existing plugins

Comments

@M0rdecay
Copy link
Contributor

M0rdecay commented Mar 17, 2020

Feature Request

Proposal:

Allow using globs in the enum plugin for field and tag keys

Current behavior:

Currently, when using the Enum processor, you can select a field or tag only by their name.

Desired behavior:

It will be possible to select a list of the necessary keys or fields according to the specified mask. Mapping rules apply to the entire list.
It is expected that you can use this configuration:

[[processors.enum]]
  [[processors.enum.mapping]]
    field = "*"
    [processors.enum.mapping.value_mappings]
      False = 0
      True = 1
      Unknown = 2

Use case:

In our case, such a need arose when analyzing data from kubernetes nodes api (/api/v1/nodes).
A node condition is described by a key "status" in an array of types:

        "conditions": [
          {
            "type": "NetworkUnavailable",
            "status": "False",
            "lastHeartbeatTime": "2020-03-16T07:44:09Z",
            "lastTransitionTime": "2020-03-16T07:44:09Z",
            "reason": "CalicoIsUp",
            "message": "Calico is running on this node"
          },
          {
            "type": "MemoryPressure",
            "status": "False",
            "lastHeartbeatTime": "2020-03-17T08:15:39Z",
            "lastTransitionTime": "2020-03-16T07:42:00Z",
            "reason": "KubeletHasSufficientMemory",
            "message": "kubelet has sufficient memory available"
          },
          {
            "type": "DiskPressure",
            "status": "False",
            "lastHeartbeatTime": "2020-03-17T08:15:39Z",
            "lastTransitionTime": "2020-03-16T07:42:00Z",
            "reason": "KubeletHasNoDiskPressure",
            "message": "kubelet has no disk pressure"
          },
          {
            "type": "PIDPressure",
            "status": "False",
            "lastHeartbeatTime": "2020-03-17T08:15:39Z",
            "lastTransitionTime": "2020-03-16T07:42:00Z",
            "reason": "KubeletHasSufficientPID",
            "message": "kubelet has sufficient PID available"
          },
          {
            "type": "Ready",
            "status": "True",
            "lastHeartbeatTime": "2020-03-17T08:15:39Z",
            "lastTransitionTime": "2020-03-16T07:43:51Z",
            "reason": "KubeletReady",
            "message": "kubelet is posting ready status"
          }
        ]

You cannot use he converter processor, because the status key can take values ​​not only True or False, but also Unknown.

The kube_inventory plugin also does not provide this information, so we use a direct request to api and then analyze the received JSON.

Since we are forced to pass a top-level array to the JSON parser (so as not to lose the metedata.name key with the node name), conditions are written as fields status_conditions_%NUMBER%_type or status_conditions_%NUMBER%_status. Then we use the pivot processor.
I note that there are many such processors required, since we are polling several APIs, so we would like to avoid specifying the order of their work and using enum for every possible situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants