# Monitoring

[![image.png](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/scaled-1680-/image.png)](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/image.png)


### Ajouter un Dashboard pour un serveur Apache dans google cloud : 

<span style="text-decoration: underline;">**Installer l'agent sur le serveur :** </span>

```shell
:> agents_to_install.csv && \
echo '"projects/XXXXXXXXX/zones/europe-west1-b/instances/YYYYYYYYYY","[{""type"":""ops-agent""}]"' >> agents_to_install.csv && \
curl -sSO https://dl.google.com/cloudagents/mass-provision-google-cloud-ops-agents.py && \
python3 mass-provision-google-cloud-ops-agents.py --file agents_to_install.csv
```

<p class="callout warning">Assurez-vous d'avoir un agent de version 2.7 ou plus ! </p>

<span style="text-decoration: underline;">**Vérifier que le serveur apache renvoie bien un statut :** </span>

```shell
curl localhost:80/server-status?auto
```

```
ServerVersion: Apache/XXXXX (Debian) OpenSSL/XXXXXX
ServerMPM: prefork
Server Built: 2022-06-20T19:03:00
CurrentTime: Saturday, 25-Feb-2023 01:06:32 UTC
RestartTime: Saturday, 25-Feb-2023 00:47:07 UTC
ParentServerConfigGeneration: 4
ParentServerMPMGeneration: 3
ServerUptimeSeconds: 1165
ServerUptime: 19 minutes 25 seconds
Load1: 0.04
Load5: 0.08
Load15: 0.18
Total Accesses: 119
Total kBytes: 1445
Total Duration: 96516
CPUUser: .66
CPUSystem: .29
CPUChildrenUser: 10.2
CPUChildrenSystem: 2.38
CPULoad: 1.16137
Uptime: 1165
```

<span style="text-decoration: underline;">**Configurer l'agent sur le serveur :** </span>

```shell
# Configures Ops Agent to collect telemetry from the app and restart Ops Agent.

set -e

# Create a back up of the existing file so existing configurations are not lost.
sudo cp /etc/google-cloud-ops-agent/config.yaml /etc/google-cloud-ops-agent/config.yaml.bak

# Configure the Ops Agent.
sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
metrics:
  receivers:
    apache:
      type: apache
  service:
    pipelines:
      apache:
        receivers:
          - apache
logging:
  receivers:
    apache_access:
      type: apache_access
    apache_error:
      type: apache_error
  service:
    pipelines:
      apache:
        receivers:
          - apache_access
          - apache_error
EOF

sudo service google-cloud-ops-agent restart
```

\[GOOGLE CLOUD\] - gestion de la facturation des logs : [https://youtu.be/crHSHI\_m2Ng](https://youtu.be/crHSHI_m2Ng)

<u>Importer le Dashboard : </u>

Se rendre sur [https://console.cloud.google.com/monitoring/dashboards](https://console.cloud.google.com/monitoring/dashboards) dans "Bibiliothéque d'exemples. Séléctionner Apache GCE Overview et cliquer sur importer :

[![image-1677287282502.png](https://docs.nehemiebarkia.fr/uploads/images/gallery/2023-02/scaled-1680-/image-1677287282502.png)](https://docs.nehemiebarkia.fr/uploads/images/gallery/2023-02/image-1677287282502.png)

<span style="text-decoration: underline;">Puis confirmer l'import : </span>

[![image-1677287362280.png](https://docs.nehemiebarkia.fr/uploads/images/gallery/2023-02/scaled-1680-/image-1677287362280.png)](https://docs.nehemiebarkia.fr/uploads/images/gallery/2023-02/image-1677287362280.png)

<span style="text-decoration: underline;">Le tableau de bord devrait s'afficher dans la liste des Dashs personalisés : </span>

[![image-1677287434352.png](https://docs.nehemiebarkia.fr/uploads/images/gallery/2023-02/scaled-1680-/image-1677287434352.png)](https://docs.nehemiebarkia.fr/uploads/images/gallery/2023-02/image-1677287434352.png)

<span style="text-decoration: underline;">Voici un exemple de l'affichage du tableau : </span>

[![image-1677287539011.png](https://docs.nehemiebarkia.fr/uploads/images/gallery/2023-02/scaled-1680-/image-1677287539011.png)](https://docs.nehemiebarkia.fr/uploads/images/gallery/2023-02/image-1677287539011.png)

[![image.png](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/scaled-1680-/pXmimage.png)](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/pXmimage.png)

[![image.png](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/scaled-1680-/1w3image.png)](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/1w3image.png)

[![image.png](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/scaled-1680-/e1Timage.png)](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/e1Timage.png)

[![image.png](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/scaled-1680-/7L4image.png)](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/7L4image.png)

[![image.png](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/scaled-1680-/DXlimage.png)](https://docs.nehemiebarkia.fr/uploads/images/gallery/2025-12/DXlimage.png)