[#222]:MCP edits - #223
[#222]:MCP edits#223Maskoff0 wants to merge 1 commit into
Conversation
| step: &str, | ||
| ) -> Result<String> { | ||
| let promql = format!( | ||
| r#"sum by(container_name) (rate(cortexbrain_cpu_bytes_alloc{{container_name=~".*{container_name}.*"}}[{timeframe}]))"# |
There was a problem hiding this comment.
Hi @Maskoff0, I found a potential issue related to this part of the code. I tested this patch with both k8s (minikube) and Docker, and while using Kubernetes, this line turns out to be a problem because the attached metadata are {command,job,container_id,k8s_pod_name,tgid} while in Docker environments we have the following metadata: {command,job,container_id,container_name,tgid}
For example:
- cortexbrain_enter_mem_alloc{command="storage-provisi",container_id="cb8e239f-7384-4f6a-a61a-f4ef71baddb3",job="cortexflow/cortexflow-metrics",k8s_pod_name="storage-provisioner",tgid="53748"}
while with Docker the metadata is the following: - cortexbrain_bytes_alloc_events_total{command="node",container_id="13b64ce3bcd6bac01fb2ce7d6478692c77d80638f665b86b58a21faa90ae5c1e",container_name="skyops-dashboard-app",job="unknown_service:cortexflow-metrics",tgid="573376"}
You can handle these cases by checking whether the Kubernetes API returns a response. If the kubernetes api returns a response, you can use the k8s_pod_name in the Prometheus query instead; if the kubernetes api doesn’t return a response, you can use the container name.
I used the same logic in the service_cache.rs file in the populate_map_with_pod_info function. With Client::try_default().await.is_ok() you can try to establish the connection to the API and from here you can handle the cases
What do you think?
There was a problem hiding this comment.
In case you can't access the service_cache.rs file you need to sync your main branch :)
Having to improve the MCP from a simple Prometheus query string adapater to a real MCP metrics server.
This are the changes made:
Important shifting to giving time series reponse.
Any recommendations or criticsm welcomed...