apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-k8s-rules
  namespace: tectonic-system
  labels:
    role: prometheus-rulefiles
    prometheus: k8s
data:
  recording.rules: |+
    pod_name:container_memory_usage_bytes:sum = sum by(pod_name) (
      container_memory_usage_bytes{container_name!="POD",pod_name!=""}
    )
    pod_name:container_spec_cpu_shares:sum = sum by(pod_name) (
      container_spec_cpu_shares{container_name!="POD",pod_name!=""}
    )
    pod_name:container_cpu_usage:sum = sum by(pod_name) (
      rate (container_cpu_usage_seconds_total{container_name!="POD",pod_name!=""}[5m])
    )
    pod_name:container_fs_usage_bytes:sum = sum by(pod_name) (
      container_fs_usage_bytes{container_name!="POD",pod_name!=""}
    )
    namespace:container_memory_usage_bytes:sum = sum by(namespace) (
      container_memory_usage_bytes{container_name!=""}
    )
    namespace:container_spec_cpu_shares:sum = sum by(namespace) (
      container_spec_cpu_shares{container_name!=""}
    )
    namespace:container_cpu_usage:sum = sum by(namespace) (
      rate (container_cpu_usage_seconds_total{container_name!="POD"}[5m])
    )
    instance:node_cpu:rate:sum = sum by(instance) (
      rate(node_cpu{mode!="idle",mode!="iowait",mode!~"guest.*"}[1m])
    )
    instance:node_filesystem_usage:sum = sum by(instance) (
      (node_filesystem_size{mountpoint="/"} - node_filesystem_free{mountpoint="/"})
    )
    instance:node_network_receive_bytes:rate:sum = sum by(instance) (
      rate(node_network_receive_bytes[1m])
    )
    instance:node_network_transmit_bytes:rate:sum = sum by(instance) (
      rate(node_network_transmit_bytes[1m])
    )
