Done!

How to create a user in Grafana using grafana-cli command line interface?

Technology
Computer Science
Engineering

Progress

6 steps completed!17.11 sec

Answer

To create a user in Grafana using the grafana-cli command line interface, you can use the following command:

grafana-cli admin reset-admin-password <new_password>

However, the grafana-cli does not support creating users directly. Instead, you typically need to create users through the Grafana UI or by using the Grafana API.

If you want to create a user via the API, you can use a POST request to the /api/admin/users endpoint. Here's an example using curl:

curl -X POST http://<your-grafana-instance>/api/admin/users \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <your_api_token>" \ -d '{ "login": "newuser", "email": "[email protected]", "password": "newpassword", "name": "New User", "role": "Viewer" // or "Editor" or "Admin" }'

Replace <your-grafana-instance>, <your_api_token>, and the user details with those appropriate for your setup.

Make sure you have the necessary permissions to create users when using the API.