# Metricbeat gives me certificate issue

**URL:** https://discuss.elastic.co/t/metricbeat-gives-me-certificate-issue/255590
**Category:** Beats
**Tags:** docker, metricbeat
**Created:** [November 16, 2020, 8:15pm UTC](https://discuss.elastic.co/t/metricbeat-gives-me-certificate-issue/255590 "2020-11-16T20:15:38Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![adityak248](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@adityak248](https://discuss.elastic.co/u/adityak248)
#### Post date: [November 16, 2020, 8:15pm UTC](https://discuss.elastic.co/t/metricbeat-gives-me-certificate-issue/255590/1 "2020-11-16T20:15:39Z")

</div>

Hello Team,

I have been trying to configure the metricbeat over SSL and i keep getting the following error

```auto
metricbeat_1 | Exiting: error initializing publisher: 2 errors: open $CERTS_DIR/elk/elk.crt: no such file or directory $CERTS_DIR/elk/elk.crt; open $CERTS_DIR/ca/ca.crt: no such file or directory reading $CERTS_DIR/ca/ca.crt

```

I have added the cert volume to the metricbeat container as well. Please let me know if there is anything that should be done more.

Here are my configs  
metricbeat.yml

```auto
#-------------------------------- Autodiscovery -------------------------------
# Autodiscover allows you to detect changes in the system and spawn new modules as they happen.
metricbeat.autodiscover:
  providers:
    - type: docker
      # https://www.elastic.co/guide/en/beats/metricbeat/current/configuration-autodiscover-hints.html
      hints.enabled: true

metricbeat.modules:
#------------------------------- System Module -------------------------------
- module: system
  metricsets: ["cpu", "load", "memory", "network", "process", "process_summary", "core", "diskio", "socket"]
  processes: ['.*']
  process.include_top_n:
    by_cpu: 5
    by_memory: 5
  period: 10s
  cpu.metrics: ["percentages"]
  core.metrics: ["percentages"]

- module: system
  period: 1m
  metricsets:
    - filesystem
    - fsstat
  processors:
  - drop_event.when.regexp:
      system.filesystem.mount_point: '^/(sys|cgroup|proc|dev|etc|host|lib)($|/)'

- module: system
  period: 15m
  metricsets:
    - uptime

#------------------------------- Docker Module -------------------------------
- module: docker
  metricsets: ["container", "cpu", "diskio", "healthcheck", "info", "memory", "network"]
  hosts: ["unix:///var/run/docker.sock"]
  period: 10s

#================================ Processors ===================================
processors:
- add_cloud_metadata: ~
- add_docker_metadata: ~
- add_locale:
    format: offset
- add_host_metadata:
    netinfo.enabled: true

#========================== Elasticsearch output ===============================
output.elasticsearch:
  hosts: "elk:9200"
  protocol: "https"
  username: $ELASTICSEARCH_USERNAME
  password: $ELASTICSEARCH_PASSWORD
  ssl.certificate_authorities: ["$CERTS_DIR/ca/ca.crt"]
  ssl.certificate: "$CERTS_DIR/elk/elk.crt"
  ssl.key: "$CERTS_DIR/elk/elk.key"

#============================== Dashboards =====================================
setup.dashboards:
  enabled: true

#============================== Kibana =========================================
setup.kibana:
  host: "kibana:5601"
  protocol: "https"
  username: $ELASTICSEARCH_USERNAME
  password: $ELASTICSEARCH_PASSWORD
  ssl.enabled: true
  ssl.verification_mode: full
  ssl.certificate_authorities: ["$CERTS_DIR/ca/ca.crt"]
  ssl.certificate: "$CERTS_DIR/elk/elk.crt"
  ssl.key: "$CERTS_DIR/elk/elk.key"

#============================== Logging =========================================

logging.level: info
logging.to_files: true
logging.files:
  path: /var/log/metricbeat
  name: metricbeat
  rotateeverybytes: 104857600 # = 100MB
  keepfiles: 3
  permissions: 0600
#============================== Xpack Monitoring ===============================
xpack.monitoring:
  enabled: true
  elasticsearch:

```

docker-compose.yaml

```auto
metricbeat:
    hostname: metricbeat
    user: root #To read the docker socket
    image: docker.elastic.co/beats/metricbeat:$VERSION
    logging:
      options:
        max-file: "3"
        max-size: "50m"
  # cap_add:
  # - AUDIT_CONTROL
  # - AUDIT_READ
    volumes:
      - certs:$CERTS_DIR:ro
      - ./metricbeat/metricbeat.yml:/usr/share/metricbeat/metricbeat.yml:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro
      - /proc:/hostfs/proc:ro
      - /:/hostfs:ro
    depends_on:
      - elk
    environment:
      - ELASTICSEARCH_URL=["$ELASTICSEARCH_HOST"]
      - ELASTICSEARCH_USERNAME=$ELASTICSEARCH_USERNAME
      - ELASTICSEARCH_PASSWORD=$ELASTICSEARCH_PASSWORD
      - KIBANA_URL=$KIBANA_HOST

```

---

<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: [December 14, 2020, 10:15pm UTC](https://discuss.elastic.co/t/metricbeat-gives-me-certificate-issue/255590/2 "2020-12-14T22:15:44Z")

</div>

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