[SOLVED] Query API from Grafana.

itNGO

Renowned Member
Jun 12, 2020
899
243
68
46
Germany
it-ngo.com
There exists the "JSON-API" Data-Source for Grafana. LINK
We are trying to use this to connect to the Proxmox Mail Gateway API to create some nice "real-time" Dashboards in Grafana to display tracking center data.

However, we have problems to authorize against the Proxmox API. Maybe someone else has done this already and can share some help?
 
HI,

PMG at the moment doesn't support API Tokens. So you would need to send a request to the /access/ticket endpoint. You can include your credentials in the request body as json like so:
Code:
{
    "username": "{{username}}",
    "password": "{{password}}",
    "realm": "pam"
}

You'll get something like this in return:
Code:
{
    "data": {
        "ticket": "{{ticket}}",
        "CSRFPreventionToken": "",
        "username": "{{username}}@{{realm}}",
        "role": "{{username}}"
    }
}

You'll need the ticket to keep authenticating your request, but that will expire regularly so you'll also need to refresh it regularly. Some more information can be found in the API viewer [1].

[1]: https://pmg.proxmox.com/pmg-docs/api-viewer/index.html#/access/ticket
 
Last edited:
HI,

PMG at the moment doesn't support API Tokens. So you would need to send a request to the /access/ticket endpoint. You can include your credentials in the request body as json like so:
Code:
{
    "username": "{{username}}",
    "password": "{{password}}",
    "realm": "pam"
}

You'll get something like this in return:
Code:
{
    "data": {
        "ticket": "{{ticket}}",
        "CSRFPreventionToken": "",
        "username": "{{username}}@{{realm}}",
        "role": "{{username}}"
    }
}

You'll need the ticket to keep authenticating your request, but that will expire regularly so you'll also need to refresh it regularly. Some more information can be found in the API viewer [1].

[1]: https://pmg.proxmox.com/pmg-docs/api-viewer/index.html#/access/ticket
Ok, understand. But PVE does currently? Is this something that is on the roadmap for PMG? Just guessing if we can wait, until this is implemented?
 
Last edited:
Ok, understand. But PVE does currently? Is this something that is on the roadmap for PMG? Just guessing if we can wait, until this is implemented?
It might be a worthy addition - but the authentication code of PVE and PMG are quite different enough - so it's not just a minimal change.
additionally I don't expect this to be a much-used feature :
* usually PMG is setup and run by a small amount of admins and not checked too much
* I think there are tons of tools to monitoring of mail-logs - and they should readily adapt to PMG

If you want you can open an enhancement request over at https://bugzilla.proxmox.com - but as said currently I don't think it would be a much used feature (but if there are more users who would want that we could look into it)
 
  • Like
Reactions: itNGO

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!