Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metricbeat] Manifest referenced in docs for k8 deployment results in metricbeat being reported as host #7199

Closed
gingerwizard opened this issue May 29, 2018 · 4 comments
Labels
containers Related to containers use case docs enhancement

Comments

@gingerwizard
Copy link

  • Version: 6.2.4
  • Operating System: Linux K8 on GCP

The docs reference this manifest showing how to deploy metricbeat on k8 as a deployment - in order to poll the kube-state-metrics service for the kubernetes metricset. This configuration results in the metricbeat pod being reported as a host i.e. beat.name becomes the container name on all docs. This can be confusing in some visualizations.

To force it to set its hostname and beat.name to the underlying host i would suggest mounting proc and adding the switch -system.hostfs=/hostfs.
In order for the kube-state-metrics to still be contactable via DNS the following is also required:

dnsPolicy: ClusterFirstWithHostNet

e.g.

---
# Deploy singleton instance in the whole cluster for some unique data sources, like kube-state-metrics
apiVersion: apps/v1
kind: Deployment
metadata:
  name: metricbeat
  namespace: kube-system
  labels:
    k8s-app: metricbeat
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: metricbeat
  template:
    metadata:
      labels:
        k8s-app: metricbeat
    spec:
      serviceAccountName: metricbeat
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
      - name: metricbeat
        image: docker.elastic.co/beats/metricbeat:6.2.4
        imagePullPolicy: Always
        args: [
          "-c", "/etc/metricbeat.yml",
          "-e",
          "-system.hostfs=/hostfs",
        ]
        env:
        - name: CLOUD_ID
          valueFrom:
            secretKeyRef:
              name: elastic
              key: CLOUD_ID
        - name: CLOUD_AUTH
          valueFrom:
            secretKeyRef:
              name: elastic
              key: CLOUD_AUTH
        securityContext:
          runAsUser: 0
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - name: config
          mountPath: /etc/metricbeat.yml
          readOnly: true
          subPath: metricbeat.yml
        #we do this so the container isn't reported as a host and thus appears as a node
        - name: proc
          mountPath: /hostfs/proc
          readOnly: true
      volumes:
      - name: proc
        hostPath:
          path: /proc
      - name: config
        configMap:
          defaultMode: 0600
          name: metricbeat-deployment-config
@ph ph added the docs label May 29, 2018
@ph
Copy link
Contributor

ph commented May 29, 2018

@exekias or @jsoriano mind to take a look?

@ph ph added the containers Related to containers use case label May 29, 2018
@praseodym
Copy link
Contributor

When using kube-state-metrics the name of the host on which the Metricbeat pod is running is not very useful information either, is it?

@gingerwizard
Copy link
Author

It’s not but it atleast means the container doesn’t show up in host listings. Ideally it would send an empty field, but the beat could be running other modules.

@exekias
Copy link
Contributor

exekias commented May 31, 2018

Agreed, this more an aesthetic fix, as we show beat hostname in the Hosts overview dashboard, we don't want to introduce noise by reporting metricbeat container name as a host.

exekias pushed a commit to exekias/beats that referenced this issue Jun 28, 2018
Metricbeat k8s deployment is used to  poll the kube-state-metrics service
for the kubernetes metricset. This configuration results in the metricbeat pod
being reported as a host i.e. beat.name becomes the container name on
all docs. This can be confusing in some visualizations.

With this change the Metricbeat will report the underlying hostname.

Fixes elastic#7199
ruflin pushed a commit that referenced this issue Jun 28, 2018
Metricbeat k8s deployment is used to  poll the kube-state-metrics service
for the kubernetes metricset. This configuration results in the metricbeat pod
being reported as a host i.e. beat.name becomes the container name on
all docs. This can be confusing in some visualizations.

With this change the Metricbeat will report the underlying hostname.

Fixes #7199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
containers Related to containers use case docs enhancement
Projects
None yet
Development

No branches or pull requests

4 participants