change scrape interval for new relic on k8s clusters

New Relic offers a generous free tier of 100GB data ingestion. But with default 30s scrape duration, it can get used up pretty fast. You can change the scrape duration by editing the configuration as described in this article.

Get existing configuration

 1## kubectl get cm nri-bundle-nri-prometheus-config -o yaml -n newrelic
 2
 3apiVersion: v1
 4data:
 5  config.yaml: |
 6    cluster_name: civo
 7    audit: false
 8    insecure_skip_verify: false
 9    require_scrape_enabled_label_for_nodes: true
10    scrape_enabled_label: prometheus.io/scrape
11    scrape_endpoints: false
12    scrape_services: true
13    transformations: []
14    verbose: false    
15kind: ConfigMap
16metadata:
17  labels:
18    app.kubernetes.io/instance: nri-bundle
19    app.kubernetes.io/name: nri-prometheus
20    app.kubernetes.io/version: 2.12.0
21    helm.sh/chart: nri-prometheus-1.13.1
22  name: nri-bundle-nri-prometheus-config
23  namespace: newrelic
24

Add scrape_duration key to above config as follows

 1## kubectl get cm nri-bundle-nri-prometheus-config -o yaml -n newrelic
 2
 3apiVersion: v1
 4data:
 5  config.yaml: |
 6    cluster_name: civo
 7    audit: false
 8    insecure_skip_verify: false
 9    require_scrape_enabled_label_for_nodes: true
10    scrape_enabled_label: prometheus.io/scrape
11    scrape_endpoints: false
12    scrape_services: true
13    transformations: []
14    verbose: false
15    scrape_duration: "300s"    
16kind: ConfigMap
17metadata:
18  labels:
19    app.kubernetes.io/instance: nri-bundle
20    app.kubernetes.io/name: nri-prometheus
21    app.kubernetes.io/version: 2.12.0
22    helm.sh/chart: nri-prometheus-1.13.1
23  name: nri-bundle-nri-prometheus-config
24  namespace: newrelic
25