Giter Site home page Giter Site logo

Add templating about sampler HOT 7 OPEN

sqshq avatar sqshq commented on April 28, 2024
Add templating

from sampler.

Comments (7)

sqshq avatar sqshq commented on April 28, 2024

Hi @aimbot31

I'll post your comment from MR here:

I was thinking about adding a -t option to specify where the template file is located, then generate a yml file in the same directory, so the position and size can be updated properly.

The size and location are not supposed to be updated manually, it is inconvenient to do it that way. User can click/select any component and move/resize through UI.

Also there is the auto-position functionality, which automatically calculates size and location for a newly added component without position specified, to fit it in the best place on the existing dashboard. If there is not much space between existing components, the biggest component size will be reduced twice. All configurations in README do not have position - user just should not worry about it

from sampler.

aimbot31 avatar aimbot31 commented on April 28, 2024

Thanks for your comment, i think i didn't express myself correctly,

I was thinking about adding a -t option to specify where the template file is located, then generate a yml file in the same directory, so the position and size can be updated properly by the program.

If we run the config with the -c flag, it will work well, but when we will quit, it will erase our template yaml and write only yaml to update the position. That's why i thought about adding a -t option to the cli to specify where to find the template, then generate a yaml in the same directory and then use it.

Don't hesitate to comment if i'm not clear enough.

from sampler.

aimbot31 avatar aimbot31 commented on April 28, 2024

@sqshq up

from sampler.

sqshq avatar sqshq commented on April 28, 2024

Hey @aimbot31,
I'm still not quite sure why it can be useful for a user. Could you please give an example, with a template and it's usecase?

from sampler.

aimbot31 avatar aimbot31 commented on April 28, 2024

Hi @sqshq,
For example with this configuration :

  - title: K8S Node Ram Usage
    position: [[0, 20], [40, 20]]
    rate-ms: 5000
    legend:
        enabled: true
        details: false
    scale: 0
    items:
      - label: node1
        color: 178
        sample: kubectl top nodes | awk 'NR==2 {printf "%d", $5}'
      - label: node2
        sample: kubectl top nodes | awk 'NR==3 {printf "%d", $5}'
      - label: node4
        sample: kubectl top nodes | awk 'NR==4 {printf "%d", $5}'
    triggers:
      - title: RAM usage exceeded
        condition: echo "$cur > 80" |bc -l
        actions:
          terminal-bell: true
          sound: true
          visual: true
          script: 'say alert: ${label} : RAM exceeded ${cur}% of usage'
  - title: K8S Node CPU Usage
    position: [[40, 20], [40, 20]]
    rate-ms: 5000
    legend:
        enabled: true
        details: false
    scale: 0
    items:
      - label: node1
        color: 178
        sample: kubectl top nodes | awk 'NR==2 {printf "%d", $3}'
      - label: node2
        sample: kubectl top nodes | awk 'NR==3 {printf "%d", $3}'
      - label: node4
        sample: kubectl top nodes | awk 'NR==4 {printf "%d", $3}'
    triggers:
      - title: CPU usage exceeded
        condition: echo "$cur > 80" |bc -l
        actions:
          terminal-bell: true
          sound: true
          visual: true
          script: 'say alert: ${label} : CPU exceeded ${cur}% of usage'
textboxes:
  - title: Kubernetes events
    position: [[0, 0], [80, 20]]
    rate-ms: 3000
    color: 211
    sample: kubectl get events -A | grep -e "Failed" -e "NAMESPACE"

You cannot make it generic because you have to know how many nodes are present on the kubernetes cluster. The template can be useful in that case. For example :

  - title: K8S Node Ram Usage
    position: [[0, 20], [40, 20]]
    rate-ms: 5000
    legend:
        enabled: true
        details: false
    scale: 0
    items:
{{ range index, node := nodes  }}
      - label: node
        color: 178
        sample: kubectl top nodes | awk 'NR=={{ .node + 2 }} {printf "%d", $5}'
{{ end }}
    triggers:
      - title: RAM usage exceeded
        condition: echo "$cur > 80" |bc -l
        actions:
          terminal-bell: true
          sound: true
          visual: true
          script: 'say alert: ${label} : RAM exceeded ${cur}% of usage'

from sampler.

sqshq avatar sqshq commented on April 28, 2024

Hey @aimbot31, sorry for the delayed response, I'm on vacation right now.
How do you propose to pass data to the template (nodes variable in your example)? Also, do you want user to specify a config file name (which will be generated based on the template), or create it automatically (e.g. k8s-template.yaml > k8s-template-config.yaml)

from sampler.

aimbot31 avatar aimbot31 commented on April 28, 2024

Hey @sqshq, I hope your vacations are going well,

"How do you propose to pass data to the template "
This is really the main problem actually.. I'm still thinking about it..

For your second question :
The second option is what I was expecting, you specify the template and then it will generate the config in the same dir.

from sampler.

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.