Open aimbot31 opened 5 years ago
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
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.
@sqshq up
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?
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'
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
)
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.
Hi,
It could be great to have go template to loop over stuff in the yaml config file.