Grafana and PMM API

Description:

Hi guys!

I’m using PMM in version 2.39.0 and I need to perform some actions via the API.

Example of actions: create dashboard, control permissions on dashboards, create annotations on specific dashboards and other actions.

Using grafana natively, it is possible to perform these actions via api: HTTP API | Grafana documentation

PMM has an API with several very useful actions: Introduction but it does not have the options I mentioned above.

Is there any way to activate the Gratana API features in the PMM environment?

Thank you very much!

Steps to Reproduce:

Version:

2.39.0

Logs:

Expected Result:

I would like to manage the entire environment via api calls.

Actual Result:

With the options I found in the PMM api documentation, it was not possible to perform the actions.

Additional Information:

Thank you very much!

Hello @edicarlos,
I have no idea where you got that documentation link but it is VERY outdated; like years outdated :slight_smile:

Please look at our current documentation. API - Percona Monitoring and Management

@matthewb I found the same v1 link via google search and looking at your docs I was trying to find the grafana api but cant seem to get it… I have a simple bash script that backs up each dashboard on a regular basis and the normal https://xxyyzz.com/api/search is not getting me anything other than a nginx error where might the access to the grafana api exist or is it modified as it leverages grafanas api to not exist anymore?

Thanks

for dashboard_uid in $(curl -k -sS -H "Authorization: Bearer $KEY" $HOST/api/search\?query\=\& | jq -r '.[] | select( .type | contains("db")) | .uid'); do
    url=$(echo $HOST/api/dashboards/uid/$dashboard_uid | tr -d '\r')
    dashboard_json=$(curl -k -sS -H "Authorization: Bearer $KEY" $url)
    dashboard_title=$(echo $dashboard_json | jq -r '.dashboard | .title' | sed -r 's/[ \/]+/_/g')
    dashboard_version=$(echo $dashboard_json | jq -r '.dashboard | .version')
    folder_title="$(echo $dashboard_json | jq -r '.meta | .folderTitle')"

    echo "Creating: ${DIR}/${folder_title}/${dashboard_title}_v${dashboard_version}.json"
    mkdir -p "${DIR}/${folder_title}"
    echo ${dashboard_json} | jq -r {meta:.meta}+.dashboard > "${DIR}/${folder_title}/${dashboard_title}_v${dashboard_version}.json"
done

All of the grafana stuff in PMM is prefixed with /graph, so you might want to try doing that.

In fact, I’ll confirm that because this is the code I’m using for an internal tool that renders graphs from grafana and I know 100% it works because I use this daily :slight_smile:

response = requests.get("{}/graph/api/dashboards/uid/{}".format(PMMSERVER, uid), headers = headers, verify = False)

Solved!!! I could not find it… Thank you :smiley:

Hi @matthewb

The link I reported is in the official PMM documentation.

On this page API - Percona Monitoring and Management there is the link in the CI/CD integration part: "To integrate your applications or CI/CD, you can use our online interactive documentation. https://percona-pmm.readme.io/reference/introduction "

I will test the API using /graph to interact with the platform.

Thank you very much.

Hi @edicarlos,
Yea, my mistake. I discussed this with one the PMM leads. I saw the ‘v1.0’ and associated that with PMMv1, not “API Docs v1”.