2017-09-14 5 views
0

Je dois surveiller Elasticsearch (2.4) installé au-dessus du cluster k8s. J'ai 2 clients, 3 maîtres et plusieurs nœuds de données exécutés dans des pods. Après le "comment" de Stackdriver et le message "Can I run Google Monitoring Agent inside a Kubernetes Pod?", j'ai déployé un agent dans son propre Pod. Soudain, après tout, n'avez pas de métriques Elasticsearch dans StackDriver. Les seuls zéros.Surveillance de StackDriver pour Elasticsearch dans GKE

enter image description here

Toute suggestion sont plus que bienvenus.

C'est ma configuration:

Service élastique:

$kubectl describe svc elasticsearch 
Name:   elasticsearch 
Namespace:  default 
Labels:   component=elasticsearch 
      role=client 
Selector:  component=elasticsearch,role=client 
Type:   NodePort 
IP:   <IP> 
Port:   http 9200/TCP 
NodePort:  http <PORT>/TCP 
Endpoints:  <IP>:9200,<IP>:9200 
Session Affinity: None 
No events. 

déploiement Stackdriver:

apiVersion: extensions/v1beta1 
kind: Deployment 
metadata: 
    name: stackagent 
spec: 
    replicas: 1 
    strategy: 
    type: Recreate 
    template: 
    metadata: 
     labels: 
     component: monitoring 
     role: stackdriver-agent 
    spec: 
     containers: 
     - name: hslab-data-agent 
     image: StackDriverAgent:version1 

StackDriverAgent: version1 Docker:

FROM ubuntu 

WORKDIR /stackdriver 

RUN apt-get update 
RUN apt-get install curl lsb-release libyajl2 -y 
RUN apt-get clean 

COPY ./stackdriver/run.sh run.sh 
COPY ./stackdriver/elasticsearch.conf elasticsearch.conf 

RUN chmod 755 ./run.sh 
CMD ["./run.sh"] 

run.sh :

#!/bin/bash 

curl -O https://repo.stackdriver.com/stack-install.sh 

chmod 755 stack-install.sh 
bash stack-install.sh --write-gcm 

cp ./elasticsearch.conf /opt/stackdriver/collectd/etc/collectd.d/ 

service stackdriver-agent restart 

while true; do 
    sleep 60 
    agent_pid=$(cat /var/run/stackdriver-agent.pid 2>/dev/null) 

    ps -p $agent_pid > /dev/null 2>&1 
    if [ $? != 0 ]; then 
     echo "Stackdriver agent pid not found!" 
     break; 
    fi 
done 

elasticsearch.conf:

Taken de https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/elasticsearch.conf

# This is the monitoring configuration for Elasticsearch 1.0.x and later. 
# Look for ELASTICSEARCH_HOST and ELASTICSEARCH_PORT to adjust your configuration file. 
LoadPlugin curl_json 
<Plugin "curl_json"> 
    # When using non-standard Elasticsearch configurations, replace the below with 
    #<URL "http://ELASTICSEARCH_HOST:ELASTICSEARCH_PORT/_nodes/_local/stats/"> 
    # PREVIOUSE LINE 
    # <URL "http://localhost:9200/_nodes/_local/stats/"> 
    <URL "http://elasticsearch:9200/_nodes/_local/stats/"> 
     Instance "elasticsearch" 
.... 

EN MARCHE:

NAME          READY  STATUS RESTARTS AGE 
esclient-4231471109-bd4tb     1/1  Running 0   23h 
esclient-4231471109-k5pnw     1/1  Running 0   23h 
esdata-1-2524076994-898r0     1/1  Running 0   23h 
esdata-2-2426789420-zhz7j     1/1  Running 0   23h 
esmaster-1-4205943399-zj2pn    1/1  Running 0   23h 
esmaster-2-4248445829-pwq46    1/1  Running 0   23h 
esmaster-3-3967126695-w0tp2    1/1  Running 0   23h 
stackagent-3122989159-15vj1    1/1  Running 0   18h 

Répondre

0

Le problème avec l'URL de l'API de plug-in http configuration.Procédé: // elasticsearch: 9200/_nodes/** _ local **/stats/"> retournera l'information seulement pour le _local nœud qui est un client qui n'a aucun document. En outre, les données Stackdriver seront collectées sous le nœud de cluster k8s et non sous le nom de la station.

La solution partielle est de sidecar de configuration dans le nœud de données et patcher la requête elasticsearch.conf avec le nom du nœud ES correspondant:

  1. obtenir le curl [elasticsearch]:9200/_nodes/stats
  2. trouver le nom de nœud ES par le $ (nom d'hôte)
  3. patcher la configuration <URL "http://elasticsearch:9200/_nodes/<esnode_name>/stats/">

Cela permettra de recueillir les informations de noeud de données ES sous le nom de nœud de données de K8S.