# Metricbeat kubernetes module collection 401

**URL:** <https://discuss.elastic.co/t/metricbeat-kubernetes-module-collection-401/246904>\
**Category:** Beats\
**Tags:** beats-module, metricbeat\
**Created:** [August 31, 2020, 4:25am UTC](https://discuss.elastic.co/t/metricbeat-kubernetes-module-collection-401/246904 "2020-08-31T04:25:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZMMWMY](https://avatars.discourse-cdn.com/v4/letter/z/a587f6/32.png) [@ZMMWMY](https://discuss.elastic.co/u/ZMMWMY)\
**Post date:** [August 31, 2020, 4:25am UTC](https://discuss.elastic.co/t/metricbeat-kubernetes-module-collection-401/246904/1 "2020-08-31T04:25:25Z")

</div>

I can collect node data, but k8s can't

the configuration

```auto
- module: kubernetes
  metricsets:
    - node
    - system
    - pod
    - container
    - volume
  period: 10s
  host: ${NODE_NAME}
  hosts: ["https://${NODE_IP}:10250"]
  bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  ssl:
    verification_mode: none
    certificate_authorities:
      - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt

```

the log

```auto
2020-08-31T04:20:30.255Z	INFO	module/wrapper.go:259	Error fetching data for metricset kubernetes.system: error doing HTTP request to fetch 'system' Metricset data: HTTP error 401 in : 401 Unauthorized
2020-08-31T04:20:30.255Z	INFO	module/wrapper.go:259	Error fetching data for metricset kubernetes.volume: error doing HTTP request to fetch 'volume' Metricset data: HTTP error 401 in : 401 Unauthorized
2020-08-31T04:20:30.348Z	INFO	module/wrapper.go:259	Error fetching data for metricset kubernetes.container: error doing HTTP request to fetch 'container' Metricset data: HTTP error 401 in : 401 Unauthorized
2020-08-31T04:20:30.348Z	INFO	module/wrapper.go:259	Error fetching data for metricset kubernetes.node: error doing HTTP request to fetch 'node' Metricset data: HTTP error 401 in : 401 Unauthorized
2020-08-31T04:20:30.349Z	INFO	module/wrapper.go:259	Error fetching data for metricset kubernetes.pod: error doing HTTP request to fetch 'pod' Metricset data: HTTP error 401 in : 401 Unauthorized

```

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [August 31, 2020, 12:18pm UTC](https://discuss.elastic.co/t/metricbeat-kubernetes-module-collection-401/246904/2 "2020-08-31T12:18:21Z")

</div>

Hi!

Do you actually want to use `ssl`? If so you need to make sure that you are using the right certificates.  
If not you can just comment out these lines:

```auto
- module: kubernetes
  metricsets:
    - node
    - system
    - pod
    - container
    - volume
  period: 10s
  host: ${NODE_NAME}
  hosts: ["https://${NODE_IP}:10250"]
  bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  ssl:
    verification_mode: none
    #certificate_authorities:
    # - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt

```

See [https://github.com/elastic/beats/blob/f2956098ef62b0fec1ae02e7cb9659dd6b9e6fe9/deploy/kubernetes/metricbeat-kubernetes.yaml#L116](https://github.com/elastic/beats/blob/f2956098ef62b0fec1ae02e7cb9659dd6b9e6fe9/deploy/kubernetes/metricbeat-kubernetes.yaml#L116)

---

<div class="post-metadata">

**Author:** ![ZMMWMY](https://avatars.discourse-cdn.com/v4/letter/z/a587f6/32.png) [@ZMMWMY](https://discuss.elastic.co/u/ZMMWMY)\
**Post date:** [September 25, 2020, 3:05am UTC](https://discuss.elastic.co/t/metricbeat-kubernetes-module-collection-401/246904/3 "2020-09-25T03:05:44Z")

</div>

sorry for reply later  
I tried your suggestion, but it didn't work

```auto
- module: kubernetes
  metricsets:
    - node
    - system
    - pod
    - container
    - volume
  period: 10s
  namespace: 'sxc'
  host: ${NODE_NAME}
  hosts: ["https://localhost:10250"]
  bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  ssl.verification_mode: "none"

```

---

<div class="post-metadata">

**Author:** ![ZMMWMY](https://avatars.discourse-cdn.com/v4/letter/z/a587f6/32.png) [@ZMMWMY](https://discuss.elastic.co/u/ZMMWMY)\
**Post date:** [September 25, 2020, 4:28am UTC](https://discuss.elastic.co/t/metricbeat-kubernetes-module-collection-401/246904/4 "2020-09-25T04:28:01Z")

</div>

Do I need to modify the ClusterRole

---

<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:** [October 23, 2020, 6:28am UTC](https://discuss.elastic.co/t/metricbeat-kubernetes-module-collection-401/246904/5 "2020-10-23T06:28:03Z")

</div>

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