I'm looking for a solution to merge two templating variables in grafana(data source: prometheus).
My use case is:
I've my first variable:
deployment = label_values(kube_deployment_labels{namespace="$namespace"},deployment)
and the second one:
statefulset = label_values(kube_statefulset_labels{namespace="$namespace"},statefulset)
What I'm looking for is a only one dropdown menu(selector) because in my dashboard I wan't to be able to select a deployment or a statefulset but not both at the same time.
I've tried at the different side:
1) With prometheus by using a query like this:
kube_deployment_labels{namespace="$namespace"} or kube_statefulset_labels{namespace="$namespace"}
But in this case I'm not able to extract the labels(could be "deployment" or statefulset")
2) It seems not possible to perform a merge of two template variables in grafana like this:
$deployment,$statefulset
Maybe I've missed something...
Thanks,
Matt
I do it by creating two separate variable and give them same label name.
Since the label name is same it will only show one drop-down.
https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#basic-variable-options
Related
I'm deploying a chart where I can add freely-defined key-value pairs( the sonarqube helm chart specifically but that's not relevant I think).
My values file looks like this:
...
sonar.properties:
ldap.user: "myuser"
ldap.password: "mypassword"
...
Now, I don't want to write the password on the values file, but neither can I pass it directly to helm with --set ldap.password=mypassword , since it's not a parameter of the chart, and I really don't want to modify the chart.
The question is: Is there a way to have variable replacement on the values file itself?
I saw the helm --post-renderer flag but I feel like this problem is generic enough to have a simpler solution instead of sed/awk-ing around, maybe I missed something in the docs.
In Azure yaml file defining pipeline. I would like imageRepository contain name of the branch from which pipeline was executed. For example,
if I run from branch_A, I would like to have imageRepository:branch_A_image
if I run from branch_B, I would like to have imageRepository:branch_B_image
How does this conditional statement in yaml would look like? I found different bits and pieces, but could not find everything 'Build.SourceBranch'???
My ultimate goal is to have different container images for different branches. I am planning to trigger pipeline manually for now.
Maybe you are searching the Build.SourceBranch and Build.SourceBranchName. You can get more details here. It looks like this:
So the right image name should be set like this:
imageRegistory:$(Build.SourceBranchName)
In many of the calls described in the Azure DevOps REST API documentation, I need to supply the name of the organization, e.g.:
https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=5.0-preview.8
The project I can get from System.TeamProject. I would have expected something similar for organization name, something like:
System.TeamFoundationCollectionName
This does not seem to be available. I've even printed out all of my environment variables on the agent and don't see anything that fits the need exactly. Sure, I can parse it out of one of the other values, but this seems fragile since MS seems to like to change the format of URLs.
I also can't hard code the organization name because this release definition will live in multiple organizations and we don't want to have to manually update it for each. How are others solving this problem?
Try using System.TeamFoundationServerUri and System.TeamFoundationCollectionUri to build your API requests. They have the organization included in them.
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/variables?view=vsts&tabs=batch
edit: SYSTEM_TEAMFOUNDATIONSERVERURI/BUILD_PROJECTNAME/_apis/release/releases?api-version=5.0-preview.8
It looks like currently there is no such variable for the organization, also, the variables return the old URL (xxx.visualstudio.com) and not the new URL (dev.azure.com/xxx) so if you use the System.TeamFoundationCollectionName the API should work without the {organization}:
https://System.TeamFoundationCollectionName/{project}/_apis/release/releases?api-version=5.0-preview.8.
In Powershell, do this:
# Where SYSTEM_TEAMFOUNDATIONCOLLECTIONURI=https://some_org_name.visualstudio.com/
([System.Uri]$Env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI).Host.split('.')[-3] # returns 'some_org_name'
Now, just assign that to a variable and use it anywhere you like. "SYSTEM_TEAMPROJECT" is the Project Name, so no need to do any parsing there. It is already available.
I want to show multiple CPU Usage from different hosts in one graph but they all end up with the same name and I can't tell which line represents which host:
here's the snapshot.
I'm using Grafana 5.2.4 with a Zabbix plugin 3.9.1. My Zabbix version is 3.0.12.
I've tried overriding legends in Grafana but there's no such option. Also, Zabbix plugin doesn't allow connecting directly to DB, so I can't use the ALIAS BY option either. I've tried using macros in Zabbix to include host name in item name, but {HOST.NAME} just ends up as is in the item name (and not replaced by the actual values).
Any solutions will be hugely appreciated.
You should use the templating feature of the Zabbix Grafana plugin,see the attached screens and the following description for a working example.
I have a Routers Zabbix Hostgroup, so I define a Router Grafana variable to match the hosts (Routers.*), see the first screenshot.
Enable both multi-value and Select All
Then in the metrics configuration use a single metric configured this way:
Group: Routers
Host: $Router (mind the $, the variable will be expanded in real time accordingly to the selection)
Item: the common item name (i.e.: ICMP Response Time)
And you will get something similar to the second screenshot, with a host picker on top and multiple selections.
So There's a "Functions" button below each metric when we are configuring and editing our graph. There's an "Alias" option and when you hover over it you see more options. If you click on "setAlias", you can define an alias for each metric.
Since this solution requires setting each alias individually, I recommend the solution that was suggested by Simone Zabberoni above. but this one is also worth knowing since it might come in handy at times.
I am trying to update the node-exporter-full Grafana dashboard with some of our internal labels as templates. We have labels for "pod" and "servertype" which can be used to get a subset of "nodes" to list at the top of the dashboard.
I can add "pod" like:
label_values(pod)
Then I can reference "pod" in the node query as follows:
label_values(node_boot_time{job="clients",pod="$pod"}, instance)
This works. If I want to add servertype in the middle how would I pull a list of "servertype" based on "pod" which is selected?
I already know the "node" can be filtered with:
label_values(node_boot_time{job="clients",pod="$pod"},servertype="$servertype", instance)
Answer was pretty simple once I reread the documentation. Using "up" function currently and it is working fine but there may be a better solution.
node_boot_time has been changed to node_boot_time_seconds
Refer to this link to get all the name changes since prometheus 0.16.0
https://github.com/prometheus/node_exporter/issues/830