# Configuration Prometheus data in ElasticSearch via Metricbeats

**URL:** <https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222>\
**Category:** Elasticsearch\
**Created:** [July 20, 2022, 11:59pm UTC](https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222 "2022-07-20T23:59:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgkumarmca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tgkumarmca/32/76839_2.png) [@tgkumarmca](https://discuss.elastic.co/u/tgkumarmca)\
**Post date:** [July 20, 2022, 11:59pm UTC](https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222/1 "2022-07-20T23:59:06Z")

</div>

Sub: We are looking for a solution to push the Prometheus data to Elasticsearch for long term storage.

We have deployed Elasticsearch, Metric Beat, prometheus and Grafana on a kubernetes cluster. We need to push prometheus data to ElasticSearch and the grafana needs to pull prometheus data from Elasticsearch to render the data. Please help us with steps to integrate these components.

ElasticSearch Version: 8.3.2  
Metric Beat: metricbeat-7.17.3  
Prometheus: 2.27.0

Regards,  
Ganesh

---

<div class="post-metadata">

**Author:** ![TiagoQueiroz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiagoqueiroz/32/107061_2.png) [@TiagoQueiroz](https://discuss.elastic.co/u/TiagoQueiroz)\
**Post date:** [August 1, 2022, 2:06pm UTC](https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222/2 "2022-08-01T14:06:08Z")

</div>

Hi @tgkumarmca, have you looked at this blog post: [How to implement Prometheus long-term storage using Elasticsearch | Elastic Blog](https://www.elastic.co/blog/how-to-implement-prometheus-long-term-storage-using-elasticsearch) ?

I believe it can help you.

---

<div class="post-metadata">

**Author:** ![tgkumarmca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tgkumarmca/32/76839_2.png) [@tgkumarmca](https://discuss.elastic.co/u/tgkumarmca)\
**Post date:** [August 1, 2022, 3:05pm UTC](https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222/3 "2022-08-01T15:05:31Z")

</div>

@TiagoQueiroz,

Thanks for your reply. I have installed all components as per the documentation provided. Prometheus is not scraping the metrics and not pushing to the metricbeat. I have updated the remote write url to metricbeat service. I am getting following error:

Remote Write URL: [http://metricbeat-ext.elastic-system:9201/metrics](http://metricbeat-ext.elastic-system:9201/metrics)

the error logs:

ts=2022-08-01T15:04:27.769Z caller=dedupe.go:112 component=remote level=warn remote\_name=ba53bf url=[http://metricbeat-ext.elastic-system:9201/metrics](http://metricbeat-ext.elastic-system:9201/metrics) msg="Failed to send batch, retrying" err="Post "[http://metricbeat-ext.elastic-system:9201/metrics\](http://metricbeat-ext.elastic-system:9201/metrics%5C)": dial tcp 100.67.96.145:9201: connect: connection refused"

---

<div class="post-metadata">

**Author:** ![TiagoQueiroz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiagoqueiroz/32/107061_2.png) [@TiagoQueiroz](https://discuss.elastic.co/u/TiagoQueiroz)\
**Post date:** [August 1, 2022, 3:18pm UTC](https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222/4 "2022-08-01T15:18:08Z")

</div>

The log error you posted says `connect: connection refused`, it seems your Prometheus instance cannot connect to your Metricbeat instance.

Check the connectivity between the machines as well as the IP the domain is resolving to.

Also double check your Metricbeat configuration and Prometheus match (things like port, endpoint, etc).

If it does not work, please post here the configuration of Metricbeat and Prometheus. Also any error logs you see on Metricbeat or Prometheus.

---

<div class="post-metadata">

**Author:** ![tgkumarmca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tgkumarmca/32/76839_2.png) [@tgkumarmca](https://discuss.elastic.co/u/tgkumarmca)\
**Post date:** [August 1, 2022, 4:43pm UTC](https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222/5 "2022-08-01T16:43:19Z")

</div>

> [@TiagoQueiroz](#):
>
> Also double check your Metricbeat configuration and Prometheus match (things like port, endpoint, e

I have installed metricbeat-7.17.3. I have initially scraped metrics to 9201 port of the metricbeat. Below are my configurations of prometheus and metricbeat.

I just noticed that the port 9201 is being connected when I exec into the pod and curl to the localhost:9201. but, this is not working from outside pod.

Please suggest if you come across any issue like this.

## MetricBeat configuration:

```
  metricbeat.modules:
  - module: prometheus
    metricsets: ["remote_write"]
    host: "localhost"
    port: "9201"

```

Prometheus configuration as follows:

remote\_write:  
[http://metricbeat-ext.elastic-system.svc.cluster.local:9201/metrics](http://metricbeat-ext.elastic-system.svc.cluster.local:9201/metrics)

---

<div class="post-metadata">

**Author:** ![TiagoQueiroz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiagoqueiroz/32/107061_2.png) [@TiagoQueiroz](https://discuss.elastic.co/u/TiagoQueiroz)\
**Post date:** [August 1, 2022, 5:10pm UTC](https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222/6 "2022-08-01T17:10:07Z")

</div>

> [@tgkumarmca](#):
>
> I just noticed that the port 9201 is being connected when I exec into the pod and curl to the localhost:9201. but, this is not working from outside pod.

That seem to be the problem, you need to edit your pod/deployment configuration on Kubernetes to enable access to this port.

---

<div class="post-metadata">

**Author:** ![tgkumarmca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tgkumarmca/32/76839_2.png) [@tgkumarmca](https://discuss.elastic.co/u/tgkumarmca)\
**Post date:** [August 1, 2022, 5:27pm UTC](https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222/7 "2022-08-01T17:27:04Z")

</div>

Hi,  
I have already updated the port in the yaml file. although, it is not working.

---

<div class="post-metadata">

**Author:** ![TiagoQueiroz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiagoqueiroz/32/107061_2.png) [@TiagoQueiroz](https://discuss.elastic.co/u/TiagoQueiroz)\
**Post date:** [August 2, 2022, 2:33pm UTC](https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222/8 "2022-08-02T14:33:02Z")

</div>

Unfortunately I can't help more because I don't have access to your environment.

But if you cannot connect from outside the pod, and it works when testing from inside the pod, it's clearly a issue outside Metricbeat and related to you Kubernetes environment. You'll have to find out why Kubernetes is not routing the traffic to this port on the container.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 30, 2022, 2:33pm UTC](https://discuss.elastic.co/t/configuration-prometheus-data-in-elasticsearch-via-metricbeats/310222/9 "2022-08-30T14:33:18Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
