I use this code exporter metric from prometheus in rancher, run the script has error:
python3 prometheus_exporter.py --cpu --pod --sum --n "cattle-gatekeeper-system" --url "https://uat-rancher.lab1.local/k8s/clusters/c-m-n2pjd454/api/v1/namespaces/cattle-monitoring-system/services/http:rancher-monitoring-prometheus:9090/proxy" --start=20220802150000 --end=20220802155500 --step=300 --tknfile=./token --dir ./Output --report --filename WeeklyReport --loglevel debug
......
2022-08-03 19:41:31 DEBUG Starting new HTTPS connection (1): uat-rancher.lab1.local:443
2022-08-03 19:41:31 DEBUG https://uat-rancher.lab1.local:443 "GET /k8s/clusters/c-m-n2pjd454/api/v1/namespaces/cattle-monitoring-system/services/http:rancher-monitoring-prometheus:9090/proxy/api/v1/query_range?query=avg%28sum%28increase%28container_cpu_cfs_throttled_periods_total%7Bnamespace%3D%22cattle-gatekeeper-system%22%2Cpod%3D~%22.%2A%22%2Cpod%21~%22%22%2Ccontainer%21~%22POD%7C%22%7D%5B5m%5D%29%29+by+%28container%2Cpod%29+%2F+sum%28increase%28container_cpu_cfs_periods_total%7Bnamespace%3D%22cattle-gatekeeper-system%22%2Cpod%3D~%22.%2A%22%2Cpod%21~%22%22%2Ccontainer%21~%22POD%7C%22%7D%5B5m%5D%29%29+by+%28container%2Cpod%29%29+%2A+on%28namespace%2C+pod%29+group_left%28workload%2C+workload_type%29+namespace_workload_pod%3Akube_pod_owner%3Arelabel%7B%7D%29+by+%28namespace%2C+workload_type%2C+workload%2C+container%29&start=2022-08-02T15%3A00%3A00.000000Z&end=2022-08-02T15%3A55%3A00.000000Z&step=300 HTTP/1.1" 400 116
2022-08-03 19:41:31 DEBUG Status code: 400
2022-08-03 19:41:31 ERROR Status code: 400
2022-08-03 19:41:31 ERROR Prometheus query failed
2022-08-03 19:41:31 ERROR {'query': 'avg(sum(increase(container_cpu_cfs_throttled_periods_total{namespace="cattle-gatekeeper-system",pod=".*",pod!"",container!"POD|"}[5m])) by (container,pod) / sum(increase(container_cpu_cfs_periods_total{namespace="cattle-gatekeeper-system",pod=".*",pod!"",container!"POD|"}[5m])) by (container,pod)) * on(namespace, pod) group_left(workload, workload_type) namespace_workload_pod:kube_pod_owner:relabel{}) by (namespace, workload_type, workload, container)', 'start': '2022-08-02T15:00:00.000000Z', 'end': '2022-08-02T15:55:00.000000Z', 'step': '300'}
2022-08-03 19:41:31 ERROR <Response [400]>
2022-08-03 19:41:31 ERROR b'{"status":"error","errorType":"bad_data","error":"1:411: parse error: unexpected right parenthesis ')'"}'
Can help me ? thanks a lot.