ditto icon indicating copy to clipboard operation
ditto copied to clipboard

Extended search based operator metrics

Open alstanchev opened this issue 8 months ago • 0 comments

It would be nice to be able to define search metrics based on the search API.

It should be possible to tag devices with predefined values in the config as well as with resolved such from the things themselves. All devices that match a filter and have the same tags should be aggregated under one metric instrument. A cleanup functionality may be needed as there might be left out instruments for things that are deleted. The configuration would as an extension to the already existing operator-metrics functionality.

operator-metrics {
      enabled = true
      scrape-interval = 30m
      custom-metrics {
        ...
      }
      custom-search-metrics {
        online_status {
          enabled = true
          scrape-interval = 20m # override scrape interval, run every 20 minute
          namespaces = [
            "org.eclipse.ditto"
          ]
          tags: {
            "online" = "{{online_placeholder}}"
            "location" = "{{attributes/Info/location}}"
          }
          filters = {
            online-filter = {
              filter = "gt(features/ConnectionStatus/properties/status/readyUntil/,time:now)"
              inline-placeholder-values = {
                // inline-placeholder-values are used to define hardcoded values to be used in the tags values if the placeholders are not json paths to an actual field in the thing
                // this is used to define different tags values based on the filter that matched the thing
                "online_placeholder" = true
              }
              // in order to do placeholder resolving from thing fields, the fields should be defined in the fields array
              // by default only the thingId is available for placeholder resolving
              fields = ["attributes/Info/location"]
              // The metric-value is used to define the value of the metric for the thing that matched the filter.
              // It does not support placeholders and should be a numeric value
            }
            offline-filter = {
              filter = "lt(features/ConnectionStatus/properties/status/readyUntil/,time:now)"
              inline-placeholder-values = {
                "online_placeholder" = false
              }
              fields = ["attributes/Info/location"]
            }
          }
        }
      }
    }

alstanchev avatar Jun 24 '24 05:06 alstanchev