apiVersion: v1
data:
  config.yaml: |
    rules:      
    - seriesQuery: 'flink_taskmanager_job_task_operator_KafkaSourceReader_KafkaConsumer_records_lag_max{kubernetes_namespace!="",kubernetes_pod_name!=""}'
      seriesFilters:
      - is: ".*flink_taskmanager_job_task_operator_KafkaSourceReader_KafkaConsumer_records_lag_max.*"
      name: {as: "lag_rate"}
      resources:
        overrides:
          kubernetes_namespace: {resource: "namespace"}
          kubernetes_pod_name: {resource: "pod"}
      metricsQuery: '(((sum(flink_taskmanager_job_task_operator_KafkaSourceReader_KafkaConsumer_records_lag_max * flink_taskmanager_job_task_operator_KafkaSourceReader_KafkaConsumer_assigned_partitions)  by (<<.GroupBy>>) - 50000) / (abs(sum(flink_taskmanager_job_task_operator_KafkaSourceReader_KafkaConsumer_records_lag_max * flink_taskmanager_job_task_operator_KafkaSourceReader_KafkaConsumer_assigned_partitions)  by (<<.GroupBy>>)- 50000)))*(1 + deriv(sum(flink_taskmanager_job_task_operator_KafkaSourceReader_KafkaConsumer_records_lag_max * flink_taskmanager_job_task_operator_KafkaSourceReader_KafkaConsumer_assigned_partitions) by (<<.GroupBy>>)[1m:2s]) / sum(avg_over_time(flink_taskmanager_job_task_operator_KafkaSourceReader_KafkaConsumer_records_consumed_rate[1m])) by (<<.GroupBy>>))) * scalar((deriv(flink_jobmanager_numRegisteredTaskManagers[2m]) == bool 0))'  
    - seriesQuery: 'flink_taskmanager_job_task_idleTimeMsPerSecond{kubernetes_namespace!="",kubernetes_pod_name!=""}'
      seriesFilters:
      - is: ".*flink_taskmanager_job_task_idleTimeMsPerSecond.*"
      name: {as: "utilization"}
      resources:
        overrides:
          kubernetes_namespace: {resource: "namespace"}
          kubernetes_pod_name: {resource: "pod"}
      metricsQuery: '(1 - (avg(flink_taskmanager_job_task_idleTimeMsPerSecond) by (<<.GroupBy>>) / 1000)) * scalar((deriv(flink_jobmanager_numRegisteredTaskManagers[2m]) == bool 0))'  
kind: ConfigMap
metadata:
  annotations:
    meta.helm.sh/release-name: my-release
    meta.helm.sh/release-namespace: default
  labels:
    app.kubernetes.io/component: metrics
    app.kubernetes.io/instance: my-release
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: prometheus-adapter
    app.kubernetes.io/part-of: prometheus-adapter
    app.kubernetes.io/version: v0.9.1
    helm.sh/chart: prometheus-adapter-3.0.0
  name: my-release-prometheus-adapter2
  namespace: default
