# Metricbeat on kubernetes

**URL:** https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524
**Category:** Beats
**Tags:** metricbeat
**Created:** [December 19, 2017, 11:31pm UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524 "2017-12-19T23:31:08Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![kanthimathi](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kanthimathi](https://discuss.elastic.co/u/kanthimathi)
#### Post date: [December 19, 2017, 11:31pm UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/1 "2017-12-19T23:31:08Z")

</div>

I am a novice user and just started to explore metric beats. I wanted to monitor kubernetes, right now I am using the cloud trial version. The issue is I couldn't get the data from kubernetes into the elastic cloud.However, my local system logs are alone being ingested into the cloud. I followed the documentation provided on the elastic site but end up getting the same error and the logs are not being pushed.

In metribeat.yml file I changed my elastic cloud setting, provided with cloud id and cloud.auth and in output part i changed my elastic search output by providing the cloud elastic search host address in the host part and corresponding credentials.

In metricbeat-kubernetes.yaml , I changed the following,

output.elasticsearch:  
hosts: ['${ELASTICSEARCH\_HOST:https://......:9243}:${ELASTICSEARCH\_PORT:9243}']  
username: ${ELASTICSEARCH\_USERNAME}  
password: ${ELASTICSEARCH\_PASSWORD}

# Deploy a Metricbeat instance per node for node metrics retrieval

apiVersion: extensions/v1beta1

env:  
- name: ELASTICSEARCH\_HOST  
value: https://......:9243  
- name: ELASTICSEARCH\_PORT  
value: "9243"  
- name: ELASTICSEARCH\_USERNAME  
value: elastic  
- name: ELASTICSEARCH\_PASSWORD  
value: $$$$  
- name: ELASTIC\_CLOUD\_ID  
value: $$$:#####  
- name: ELASTIC\_CLOUD\_AUTH  
value: @@@:####

similarly in # Deploy singleton instance in the whole cluster for some unique data sources, like kube-state-metrics

when i try to deploy on kubernetes, i get the following error.

kubectl create -f metricbeat-kubernetes.yaml  
W1220 12:12:38.296990 1982 factory\_object\_mapping.go:423] Failed to download OpenAPI (the server could not find the requested resource), falling back to swagger

Can somebody please help ? ☹

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [December 19, 2017, 11:57pm UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/2 "2017-12-19T23:57:13Z")

</div>

Hi @kanthimathi!

I have noticed something wrong in your settings:

```auto
- name: ELASTICSEARCH_HOST
  value: https://......:9243

```

:Port should be removed from ELASTICSEARCH\_HOST, as it's defined in ELASTICSEARCH\_PORT.

Also, could you paste the full output for `kubectl create` command? I think the swagger message is just a warning

---

<div class="post-metadata">

### Author: ![kanthimathi](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kanthimathi](https://discuss.elastic.co/u/kanthimathi)
#### Post date: [December 20, 2017, 12:18am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/3 "2017-12-20T00:18:10Z")

</div>

This is the message i get after running kubectl create command,

`kubectl create -f metricbeat-kubernetes.yaml W1220 13:16:09.739901 2256 factory_object_mapping.go:423] Failed to download OpenAPI (the server could not find the requested resource), falling back to swagger Error from server (AlreadyExists): error when creating "metricbeat-kubernetes.yaml": configmaps "metricbeat-config" already exists Error from server (AlreadyExists): error when creating "metricbeat-kubernetes.yaml": configmaps "metricbeat-daemonset-modules" already exists Error from server (AlreadyExists): error when creating "metricbeat-kubernetes.yaml": daemonsets.extensions "metricbeat" already exists Error from server (AlreadyExists): error when creating "metricbeat-kubernetes.yaml": configmaps "metricbeat-deployment-modules" already exists Error from server (AlreadyExists): error when creating "metricbeat-kubernetes.yaml": deployments.extensions "metricbeat" already exists Error from server (AlreadyExists): error when creating "metricbeat-kubernetes.yaml": serviceaccounts "metricbeat" already exists`

I did edit the port as u mentioned but still i couldn't find the kuberenetes log in cloud. However, i can view my local host logs

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [December 20, 2017, 12:32am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/4 "2017-12-20T00:32:52Z")

</div>

The problem now is that you already deployed the wrong conf (new error says `Error from server (AlreadyExists)`). You can fix this by removing and creating metricbeat again:

```auto
kubectl delete -f metricbeat-kubernetes.yaml
kubectl create -f metricbeat-kubernetes.yaml

```

Best regards

---

<div class="post-metadata">

### Author: ![kanthimathi](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kanthimathi](https://discuss.elastic.co/u/kanthimathi)
#### Post date: [December 20, 2017, 12:40am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/5 "2017-12-20T00:40:13Z")

</div>

Thanks for the timely help

`kubectl create -f metricbeat-kubernetes.yaml W1220 13:35:46.373417 2431 factory_object_mapping.go:423] Failed to download OpenAPI (the server could not find the requested resource), falling back to swagger configmap "metricbeat-config" created configmap "metricbeat-daemonset-modules" created daemonset "metricbeat" created configmap "metricbeat-deployment-modules" created deployment "metricbeat" created serviceaccount "metricbeat" created`

still the same issue ☹ no logs in cloud

Thanks,

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [December 20, 2017, 12:57am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/6 "2017-12-20T00:57:50Z")

</div>

You will probably want to see what's going on in the logs, you can check them by following these steps:

- List failing pods with `kubectl get pod --namespace=kube-system`
- Chose one of the metricbeat pods
- Get logs from it: `kubectl logs --namespace=kube-system <metricbeat-pod-name>`

Best regards

---

<div class="post-metadata">

### Author: ![kanthimathi](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kanthimathi](https://discuss.elastic.co/u/kanthimathi)
#### Post date: [December 20, 2017, 1:01am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/7 "2017-12-20T01:01:35Z")

</div>

> [@exekias](#):
>
> kubectl logs --namespace=kube-system

when i tried to do so

`Error from server (BadRequest): container "metricbeat" in pod "metricbeat-2s5tb" is waiting to start: trying and failing to pull image`

got this message.

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [December 20, 2017, 1:04am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/8 "2017-12-20T01:04:23Z")

</div>

Uhm, error says `docker pull` is failing for metricbeat image, could you please dump the result of `kubectl describe --namespace=kube-system po/metricbeat-2s5tb`?

---

<div class="post-metadata">

### Author: ![kanthimathi](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kanthimathi](https://discuss.elastic.co/u/kanthimathi)
#### Post date: [December 20, 2017, 1:07am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/9 "2017-12-20T01:07:59Z")

</div>

> [@exekias](#):
>
> kubectl describe --namespace=kube-system po/metricbeat-2s5tb

 ![53 PM](https://us1.discourse-cdn.com/elastic/original/3X/9/9/99a579ab42837591fa35a9a42738c4a94d0afe75.png)  
 ![20 PM](https://us1.discourse-cdn.com/elastic/original/3X/2/5/252d4091326017f27f6a7ddb5722309a71dcd6a9.png)

Got this

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [December 20, 2017, 1:09am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/10 "2017-12-20T01:09:50Z")

</div>

Ok you got the docs from master, which includes a non released version, could you please replace all image instances and change `7.0.0-alpha1` to `6.1.1`?

Then you will need to recreate, with delete + create

---

<div class="post-metadata">

### Author: ![kanthimathi](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kanthimathi](https://discuss.elastic.co/u/kanthimathi)
#### Post date: [December 20, 2017, 1:15am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/11 "2017-12-20T01:15:55Z")

</div>

finally made it 😃 thanks a ton

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [December 20, 2017, 1:17am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/12 "2017-12-20T01:17:22Z")

</div>

Thanks for reporting! I've created an issue in our repo to fix this behavior when you are using master docs: [https://github.com/elastic/beats/issues/5930](https://github.com/elastic/beats/issues/5930)

---

<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: [January 17, 2018, 1:32am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes/112524/13 "2018-01-17T01:32:13Z")

</div>

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