Use ambari-metrics to visualize metrics exposed via AMS in Grafana.
ToC
You can install Grafana on any host. It does not need to be co-located with Ambari Metrics Collector. The only requirement is that it has network access to Ambari Metrics Collector.
Install on CentOS/Red Hat:
sudo yum install https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0-1.x86_64.rpm
Install on Ubuntu/Debian:
wget https://grafanarel.s3.amazonaws.com/builds/grafana_2.6.0_amd64.deb sudo apt-get install -y adduser libfontconfig sudo dpkg -i grafana_2.6.0_amd64.deb
Install on SUSE/SLES:
sudo rpm -i --nodeps grafana-2.6.0-1.x86_64.rpm
On your Grafana Server
cp -R ambari/ambari-metrics/ambari-metrics-grafana/ambari-metrics /usr/share/grafana/public/app/plugins/datasource
sudo service grafana-server start
http://GRAFANA_HOST:3000
Add a Datasource
- Click on “Datasources”
- Click on “Add New” at the top
Add a Datasource (continued)
- Name of your Datasource
- Type = AmbariMetrics
- Host+Port of your AMS installation. (usually host:6188)
- No trailing slashes
- Nothing else needs to be changed
- Click on Save.
To make sure it's all working, click on Test Connection and you should see a message that says “Data source is working”.
To create a dashboard
- Click on Dashboards on the left
- Click on “Home”
- Click on New at the bottom of the dropdown
To add a panel to your newly created dashboard
- Click on the green button on the left(see image below)
- This will expand a flyout menu that will allow you to add a panel
- Choose Graph / Table / Single Stat
- Choose the Datasource you created earlier
- Once you've chosen the datasource, you should see the query editor show you some options
- Choose the component you wish to see metrics for
- Based on the component chosen, you should now see a list of metrics for it
- Choose hostname from the list of hosts if you wish to see metrics for a specific host.
- if hostname isn't chosen, metrics will be shown on a service component level.
- By default the aggregator is avg. You can change it via the dropdown
- You can choose to enable Rate by selecting the checkbox.
- You can specify precision by checking the box and then selecting “days, hours, minutes or seconds”
To change the title of the Panel
- Click on the “General” tab
- Enter the name to change the title of the panel
To change the Units for your metric
- You can edit the units of your graph by clicking on Axes & Grid tab and clicking on “unit” as shown.
To customise your graphs
- You can customise your graph by clicking on the Display Styles tab.
- For ex: you can change the color of a specific metric by choosing a series specific override at the bottom.
- Click on the save icon next to the dashboard list dropdown on the top to save your dashboard.
- Click on the title of your graph/panel and click on edit.
To change the Time Range
- To change the timerange click on the top right of your UI.
- This setting affects all your graphs inside the dashboard. If you wish to customise time for a specific graph look here
- You can use the quick ranges provided or choose a time range of your choice. You can also choose a refresh duration for your dashboard or leave it at “off” to manually refresh.
To change the time range of one graph only
- Use this in case you wish to change the time range for a specific graph without affecting the other graphs in your dashboard
- Click on the Time Range tab of your Graph
- You can then enter a value in the “Override Relative time” input box
- You will be able to confirm that this change has occured by looking at the top right of your graph which will show the override message.
- You can choose to hide this message if you wish to do so (by checking the “hide time override info”)
Templating allows you to dynamically change graphs by selecting your host from dropdown. To created a templated dashboard, you can follow these steps.
- Click on the “cog” on the top, select “Templating”
- Click on “+ New”
- Enter a name for your variable. Ex: “hosts”.
- Type: query
- Datasource: This should be set to the name you had chosen for your Datasource. Default is “AMBARI_METRICS”
- Query: This needs to be “hosts”. It is case sensitive as well.
- Once you've entered the query and you focus your cursor anywhere else, you should see the “Preview of values” updated with the hostnames in your cluster.
- You can close the Templating Variables section.
- You should now have a dropdown on your dashboard with hosts from your cluster.
- When you now add a graph, and select your component and metric, the plotted graph will show you metrics for the selected hostname from the dropdown.
- The legend on the graph will also now update with the selected host.
Templated dashboards do support multiple metrics in a single graph.
Templated dashboards now have the ability to filter graphs based on a single host or multiple hosts.
- Once you've created your templated dashboard, you can edit it gain by clicking on the “cog” on the top, select “Templating”.
- Click on “Edit” for your templating variable.
- To be able to select Multiiple Hosts, set multi-value selection to “enable” and leave multi-format set to “glob”.
- To have an option for All hosts, select All Value, and set it to “*” and All format to “wildcard”.
- Hit Update and close the templating variables options and you should be now able to select multiple hosts from the dropdown (or “all” hosts at once.)