---
groups:
- name: accnw
  rules:
    - record: access:ifHCInOctets:rate
      expr: (rate(ifHCInOctets[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: access:ifHCOutOctets:rate
      expr: (rate(ifHCOutOctets[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: access:ifHCInOctets:NNI_rate
      expr: (rate(ifHCInOctets{ifAlias=~".*_NNI.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: access:ifHCOutOctets:NNI_rate
      expr: (rate(ifHCOutOctets{ifAlias=~".*_NNI.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: access:ifHCInOctets:FIX_rate
      expr: (rate(ifHCInOctets{ifAlias=~"FIX_.*|RED_.*",ifDescr!~"Tunnel.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: access:ifHCOutOctets:FIX_rate
      expr: (rate(ifHCOutOctets{ifAlias=~"FIX_.*|RED_.*",ifDescr!~"Tunnel.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: all:max_in
      expr: max_over_time(access:ifHCInOctets:rate[1d])
    - record: all:max_out
      expr: max_over_time(access:ifHCOutOctets:rate[1d])
    - record: access:min_in
      expr: min_over_time(access:ifHCInOctets:NNI_rate[1d])
    - record: access:min_out
      expr: min_over_time(access:ifHCOutOctets:NNI_rate[1d])
    - record: access:max_in
      expr: max_over_time(access:ifHCInOctets:NNI_rate[1d])
    - record: access:max_out
      expr: max_over_time(access:ifHCOutOctets:NNI_rate[1d])
    - record: access:avg_in
      expr: avg_over_time(access:ifHCInOctets:NNI_rate[1d])
    - record: access:avg_out
      expr: avg_over_time(access:ifHCOutOctets:NNI_rate[1d])
    - record: access:avg_in:12h
      expr: avg_over_time(access:ifHCInOctets:NNI_rate[12h])
    - record: access:avg_out:12h
      expr: avg_over_time(access:ifHCOutOctets:NNI_rate[12h])
    - record: fix:min_in
      expr: min_over_time(access:ifHCInOctets:FIX_rate[1d])
    - record: fix:min_out
      expr: min_over_time(access:ifHCOutOctets:FIX_rate[1d])
    - record: fix:max_in
      expr: max_over_time(access:ifHCInOctets:FIX_rate[1d])
    - record: fix:max_out
      expr: max_over_time(access:ifHCOutOctets:FIX_rate[1d])
    - record: fix:avg_in
      expr: avg_over_time(access:ifHCInOctets:FIX_rate[1d])
    - record: fix:avg_out
      expr: avg_over_time(access:ifHCOutOctets:FIX_rate[1d])
    - record: fix:avg_in:12h
      expr: avg_over_time(access:ifHCInOctets:FIX_rate[12h])
    - record: fix:avg_out:12h
      expr: avg_over_time(access:ifHCOutOctets:FIX_rate[12h])
    - record: tunnel:rate
      expr: (rate(ifHCOutOctets{ifDescr=~"Tunnel.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: tunnel:max_out
      expr: max_over_time(tunnel:rate[1d])
    - record: tunnel_4g:rate
      expr: (rate(ifHCOutOctets{ifAlias=~".*ETH.*-4G-[BE|HS].*",ifDescr=~"Tunnel.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: tunnel_3g:rate
      expr: (rate(ifHCOutOctets{ifAlias=~".*ETH.*-3G-[BE|HS].*",ifDescr=~"Tunnel.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: tunnel_2g:rate
      expr: (rate(ifHCOutOctets{ifAlias=~".*ETH.*-2G-[BE|HS].*",ifDescr=~"Tunnel.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: tunnel_fix:rate
      expr: (rate(ifHCOutOctets{ifAlias=~".*ETH.*-FIX-[BE|HS].*",ifDescr=~"Tunnel.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: tunnel_rnc:rate
      expr: (rate(ifHCOutOctets{ifAlias=~".*ETH.*-RNC-[BE|HS].*",ifDescr=~"Tunnel.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: tunnel_bsc:rate
      expr: (rate(ifHCOutOctets{ifAlias=~".*ETH.*-BSC-[BE|HS].*",ifDescr=~"Tunnel.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: tunnel_tcell:rate
      expr: (rate(ifHCOutOctets{ifAlias=~".*ETH.*-TCELL-[BE|HS].*",ifDescr=~"Tunnel.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
    - record: count_4G
      expr: count by (sysName) (ifHCInOctets{ifAlias=~".*S1_X2.*",ifDescr=~".*[.].*"} * on(instance) group_left(sysName) sysName)
    #- record: access:sysName
    #  expr: label_replace(sysName,"sysName", "$1", "sysName", "(.*)")
    #- record: access:ifAdminStatus
    #  expr: (ifAdminStatus{ifAlias=~".*_NNI.*",ifDescr!~"Tunnel.*"} * on(instance) group_left(sysName) sysName) == 2
    #- record: access:ifOperStatus
    #  expr: (ifOperStatus{ifAlias=~".*_NNI.*",ifDescr!~"Tunnel.*"} * on(instance) group_left(sysName) sysName) == 2
    - record: qinq_temos_in:rate
      expr: sum by (temos_in, sysName, instance) (label_replace((rate(ifHCInOctets{ifAlias=~"QinQ.*_NNI.*"}[10m]) * 8), "temos_in", "$1", "ifAlias", "^.*(@0.+)$") * on(instance) group_left(sysName) sysName)
    - record: qinq_temos_out:rate
      expr: sum by (temos_out, sysName, instance) (label_replace((rate(ifHCOutOctets{ifAlias=~"QinQ.*_NNI.*"}[10m]) * 8), "temos_out", "$1", "ifAlias", "^.*(@0.+)$") * on(instance) group_left(sysName) sysName)
    - record: qinq_temos_in:rate:max
      expr: max_over_time(qinq_temos_in:rate[1d])
    - record: qinq_temos_out:rate:max
      expr: max_over_time(qinq_temos_out:rate[1d])
    - record: qinq_temos_in:rate:min
      expr: min_over_time(qinq_temos_in:rate[1d])
    - record: qinq_temos_out:rate:min
      expr: min_over_time(qinq_temos_out:rate[1d])
    - record: qinq_temos_in:rate:avg
      expr: avg_over_time(qinq_temos_in:rate[12h])
    - record: qinq_temos_out:rate:avg
      expr: avg_over_time(qinq_temos_out:rate[12h])
    - record: ifHCInOctets:rate:NNIandSecGW
      expr: (rate(ifHCInOctets{ifAlias=~".*_NNI.*|.*SecGW.*"}[10m]) * 8) * on(instance) group_left(sysName) sysName
