Coder Social home page Coder Social logo

Comments (10)

pinkavaj avatar pinkavaj commented on June 16, 2024 1

The JSON metric collector is already present, but it is only used to collect metric from pods wich are managed by HPA. Metric from those pods also can be scaped by Prometheus and then used by prometheus metrics plugin, so this is a bit similar situation (but also a bit different).

I agree using Prometheus is usualy better idea, but this might help simplify some thinks.

I have already tryed to hack (I did not event tested it, the code need definitely a lot of cleanup) something which migh do what is proposed here (https://github.com/pinkavaj/kube-metrics-adapter/tree/external-json-collector).

I would guess the syntac might look somethink like:

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: myapp-hpa
  annotations:
    metric-config.external.my-metric.json-query/host: service.my-namespace.svc
    metric-config.external.my-metric.json-query/json-key: "$.mymetric.value"
    metric-config.external.my-metric.json-query/path: /metrics
    metric-config.external.my-metric.json-query/port: "8080"
    metric-config.external.my-metric.json-query/scheme: "http"
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: custom-metrics-consumer
  minReplicas: 1
  maxReplicas: 10
  metrics:
  - type: External
    external:
      metricName: my-metric
      targetAverageValue: 10

from kube-metrics-adapter.

arjunrn avatar arjunrn commented on June 16, 2024 1

There is now an external http json collector. Implemented in #122

from kube-metrics-adapter.

szuecs avatar szuecs commented on June 16, 2024

We had also issues with Prometheus, but recent versions and running with a vpa works great for us.
If you like to enhance this tool we are happy to review your pull requests. Tests are mandatory and documentation, too.

from kube-metrics-adapter.

mikkeloscar avatar mikkeloscar commented on June 16, 2024

@mzupan just to be clear. What you are asking for is something like the Prometheus external metric, but instead of Prometheus format want to hit a service which returns metrics in JSON format?

Is this correctly understood or do you mean something else? Maybe an example of the sort of metrics you would like to scale on would be helpful to understand the problem you are trying to solve.

from kube-metrics-adapter.

mzupan avatar mzupan commented on June 16, 2024

@mikkeloscar it's my understanding that this only reads metrics from the same deployment it is autoscaling?

We have a deployment called sidekiq which is a bunch of workers. I want to read metrics from a collector that pulls in queue count numbers for a deployment/service called sidekiq-exporter that I can add a json endpoint to. I want to hit the sidekiq-exporter service to autoscale the sidekiq deployment

from kube-metrics-adapter.

mikkeloscar avatar mikkeloscar commented on June 16, 2024

@mzupan thanks, I understand what you want to do now. However I'm not completely convinced it makes sense to introduce such custom collectors when we already have Prometheus which is a general solution solving this problem in a "standard" way. Seems more like a hack to work around a Prometheus which is not scaled reasonable.

I do realize that not everyone is using Prometheus so having something json based could be valuable. Can you share your ideas around how the API would look like for such a feature? I.e. how would users configure the HPA. With this in mind it's easier to discuss the feature. Thanks!

from kube-metrics-adapter.

mzupan avatar mzupan commented on June 16, 2024

@pinkavaj yes that's just what I was thinking of doing is adding a host or service attribute to the annotation

from kube-metrics-adapter.

tomaspinho avatar tomaspinho commented on June 16, 2024

@pinkavaj's work would also be very beneficial for us, what's missing for this to be merged?
EDIT: Available to help out in any way.

from kube-metrics-adapter.

pinkavaj avatar pinkavaj commented on June 16, 2024

It is proof-of concept now. It is tested to the point where metric from JSON endpoint are collected and processed, but I did not get to the point to actualy use it with any HPA. It needs a bit more testing, add proper documentation and probably write some tests.

We are now testing another metric API server, but I would gladly finish this (sinc we might revert back to this solution). It would really help if You can build and run my current implementation in the the branch mentioned above and try if it actualy works.

from kube-metrics-adapter.

mikkeloscar avatar mikkeloscar commented on June 16, 2024

Sorry I lost track of this. The proposal seems reasonable to me. I would happily review a PR with this feature.

from kube-metrics-adapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.