Elasticsearch Datasource cannot connect to secure Elasticsearch

  • What Grafana version and what operating system are you using?
    11.1.0

  • What are you trying to achieve?
    Trying to configure the Elasticsearch datasource to connect to a secured cluster (username/password authentication)

  • How are you trying to achieve it?

  • What happened?
    When clicking on “Save & Test” this message appears:

Unable to connect with Elasticsearch. Please check the server logs for more details.

When running a curl from the host where grafana is running on, all works just fine:

curl -XGET --user elastic:PASSWORD http://elasticsearch:9200/_cat/health?pretty

1729236641 07:30:41 cluster-name green 3 2 1700 854 0 0 0 0 - 100.0%

  • What did you expect to happen?
    An OK.

  • Can you copy/paste the configuration(s) that you are having problems with?
    See above image

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    When viewing the logs, it just says it got a 403 Forbidden.

  • Did you follow any online instructions? If so, what is the URL?
    Configure the Elasticsearch data source | Grafana documentation

Did you follow instructions?

So you have wrong credentials configured in the Grafana.