Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Victoria Metrics support #1860

Closed
AndrewChubatiuk opened this issue Apr 13, 2023 · 17 comments
Closed

Add Victoria Metrics support #1860

AndrewChubatiuk opened this issue Apr 13, 2023 · 17 comments
Labels
enhancement New feature or request needs-follow-up needs-triage opencost OpenCost issues vs. external/downstream

Comments

@AndrewChubatiuk
Copy link
Contributor

Is your feature request related to a problem? Please describe.
We're using Victoria Metrics for monitoring, which is provides same API as Prometheus but has a different architecture.

In a multicluster monitoring configuration instead of having Prometheus instance on each cluster Victoria Metrics provides component called VMAgent, which has no /query or /query_range endpoints. It scrapes metrics from K8s cluster and pushes them to VMCluster. VMCluster stores all metrics and has /query and /query_range endpoints to query them, but VMCluster has no /status/config endpoint (which is used by OpenCost to get scrape configuration). Opencost has ability to configure only one Prometheus endpoint for both /query and /status/config endpoints, which is not applicable for Victoria Metrics setup.

Another problem is that Opencost relies on a local Prometheus setup, that's why it doesn't filter current cluster metrics, which is not applicable for VMCluster as well.

Describe the solution you'd like
To support Victoria Metrics it's needed to:

  • add current cluster filter for all PromQL queries
  • add an optional client for scrape endpoint when it's defined
@mattray mattray added enhancement New feature or request opencost OpenCost issues vs. external/downstream labels Apr 17, 2023
@mattray
Copy link
Collaborator

mattray commented Apr 17, 2023

This sounds like a worthwhile enhancement we'd take PRs for.

@AjayTripathy do you have recommendations for how to proceed?

@AndrewChubatiuk
Copy link
Contributor Author

@mattray #1430 and #1861 should solve this issue

@mattray
Copy link
Collaborator

mattray commented Dec 18, 2023

@AndrewChubatiuk
Copy link
Contributor Author

@mattray #1861 was then reverted, this issue is not resolved

@joelhess
Copy link

@mattray Is there a current status on this? It looks like the MRs's required referenced, were merged, one was reverted, and then put back in and re-merged.

@AndrewChubatiuk
Copy link
Contributor Author

@joelhess you can partially follow a guide https://victoriametrics.com/blog/monitoring-kubernetes-costs-with-opencost-and-victoriametrics/. Unfortunately image of version 2.2.0, which contains functionality, described in a guide was removed from registry. You need to build your own image

@mattray
Copy link
Collaborator

mattray commented Apr 12, 2024

The 2.2.0 was an inadvertent Kubecost-versioned build that we've removed. OpenCost 1.110.0 should contain this and ship soon.

@joelhess
Copy link

Is there a target date for v1.110? We're trying to plan out some work and this would be helpful to know if we should just use Prom for now. (We'd much prefer Victoria as that's what we're using for everything else)

@mattray
Copy link
Collaborator

mattray commented Apr 23, 2024

We're hoping to get the release out soon, but we're blocking on getting a UI for the Carbon Costs and Datadog integration merged.

@PabloSebastian
Copy link

Is the VictoriaMetrics support included in the latest release, v1.110?

@AndrewChubatiuk
Copy link
Contributor Author

@PabloSebastian yes, it was released in 1.110. you can find information in a blog post
https://new.victoriametrics.com/blog/monitoring-kubernetes-costs-with-opencost-and-victoriametrics/

@PabloSebastian
Copy link

@AndrewChubatiuk Thanks for the quick response!
I followed that documentation. I'm working with a VictoriaMetrics vmsingle, but I got the following error:

2024-04-30T19:40:00.011925792Z ??? Log level set to info
2024-04-30T19:40:00.012051994Z INF Starting cost-model version 1.110 (a1dfd1c)
2024-04-30T19:40:00.012064494Z INF Kubernetes enabled: true
2024-04-30T19:40:00.012139095Z INF Prometheus/Thanos Client Max Concurrency set to 5
2024-04-30T19:40:00.026886311Z ERR Failed to query prometheus at http://vmsingle-victoria-metrics-k8s-stack.victoria-metrics.svc:8429/prometheus. Error: no running jobs on Prometheus at /prometheus/api/v1/query . Troubleshooting help available at: https://www.opencost.io/docs/integrations/prometheus
2024-04-30T19:40:00.028577735Z INF Retrieved a prometheus config file from: http://vmsingle-victoria-metrics-k8s-stack.victoria-metrics.svc:8429/prometheus
2024-04-30T19:40:00.028617836Z INF Using scrape interval of 60.000000
2024-04-30T19:40:00.029258045Z INF NAMESPACE: opencost
2024-04-30T19:40:00.230367689Z INF Done waiting

Do you know if it is a common issue?

@AndrewChubatiuk
Copy link
Contributor Author

AndrewChubatiuk commented Apr 30, 2024

You've copied VictoriaMetrics address from blogpost, is it available at http://vmsingle-victoria-metrics-k8s-stack.victoria-metrics.svc:8429/prometheus in your case? also have you deployed vmstack helm chart it in the same cluster in victoria-metrics namespace? What is a service name for vmsingle?

@PabloSebastian
Copy link

Yes, I have deployed the VictoriaMetrics stack in the same cluster in the victoria-metrics namespace. Here is the logs after making a kubectl get svc

$ kubectl get svc -n victoria-metrics
NAME                                                       TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)            AGE
victoria-metrics-k8s-stack-cen-kube-state-metrics          ClusterIP   10.255.26.132   <none>        8080/TCP           24d
victoria-metrics-k8s-stack-cen-prometheus-node-exporter    ClusterIP   10.255.28.53    <none>        9100/TCP           24d
victoria-metrics-k8s-stack-cen-victoria-metrics-operator   ClusterIP   10.255.11.140   <none>        8080/TCP,443/TCP   24d
vmagent-victoria-metrics-k8s-stack                         ClusterIP   10.255.14.234   <none>        8429/TCP           22d
vmsingle-victoria-metrics-k8s-stack                        ClusterIP   10.255.9.7      <none>        8429/TCP           17h

@AndrewChubatiuk
Copy link
Contributor Author

Sorry, haven't read your error correctly. this error is expected, as Opencost didn't want to support multiple prometheus endpoints (one was required to retrieve scrape config from VMAgent, another one - to scrape metrics from VMSingle). That's why scrape interval should be set manually for opencost as it's mentioned in a blog

@mattray
Copy link
Collaborator

mattray commented May 2, 2024

@AndrewChubatiuk can we close this issue?

@joelhess
Copy link

joelhess commented May 6, 2024

We're trying to follow up on this. There's another issue tracking on the helm chart repo, but we don't really think it's related there.. opencost/opencost-helm-chart#201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-follow-up needs-triage opencost OpenCost issues vs. external/downstream
Projects
None yet
Development

No branches or pull requests

4 participants