Installation de metricbeat via brew sur MacOS

33 x served & 3 x viewed

Les commandes :

$ brew tap elastic/tap
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
erlang@20                                                newman                                                   open-zwave                                               stellar-core
==> Deleted Formulae
erlang@19                                                                                                          ruby@2.0

==> Tapping elastic/tap
Cloning into '/usr/local/Homebrew/Library/Taps/elastic/homebrew-tap'...
remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 23 (delta 10), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (23/23), done.
Tapped 18 formulae (66 files, 115.6KB).


$ brew install elastic/tap/metricbeat-full
==> Installing metricbeat-full from elastic/tap
==> Downloading https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.4.2-darwin-x86_64.tar.gz?tap=elastic/homebrew-tap
######################################################################## 100.0%
==> Caveats
To have launchd start elastic/tap/metricbeat-full now and restart at login:
  brew services start elastic/tap/metricbeat-full
Or, if you don't want/need a background service you can just run:
  metricbeat
==> Summary
🍺  /usr/local/Cellar/metricbeat-full/7.4.2: 62 files, 129.7MB, built in 1 minute 27 seconds

MacOS : Prometheus : Failed to create directory for logging active queries

17 x served & 5 x viewed

J’ai pu voir que cela ne se lançait pas dans /usr/local/var/log/prometheus.err.log, sans arrêt j’ai l’erreur :

component=activeQueryTracker msg="Failed to create directory for logging active queries"

J’ai donc modifié le fichier /usr/local/Cellar/prometheus/2.13.1/homebrew.mxcl.prometheus.plist et pas le fichier  /Users/XXXXXX/Library/LaunchAgents/homebrew.mxcl.prometheus.plist (inutile)

<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
  <dict>
    <key>Label</key>
    <string>homebrew.mxcl.prometheus</string>
    <key>ProgramArguments</key>
    <array>
      <string>sh</string>
      <string>-c</string>
      <string>/usr/local/opt/prometheus/bin/prometheus $(&lt; /usr/local/etc/prometheus.args)</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <false/>
    <key>WorkingDirectory</key>
    <string>/usr/local/opt/prometheus</string>
    <key>StandardErrorPath</key>
    <string>/usr/local/var/log/prometheus.err.log</string>
    <key>StandardOutPath</key>
    <string>/usr/local/var/log/prometheus.log</string>
  </dict>
</plist>

Je relance :

$ brew services restart prometheus
Stopping `prometheus`... (might take a while)
==> Successfully stopped `prometheus` (label: homebrew.mxcl.prometheus)
==> Successfully started `prometheus` (label: homebrew.mxcl.prometheus)

Attention pour l’écoute c’est 0.0.0.0 et pas 127.0.0.1 : http://0.0.0.0:9090 .

MacOS : MotionProHttp dans system.log : com.arraynetworks.mhttpd : Service exited with abnormal code: 3

21 x served & 7 x viewed

Quand je fais des statistiques sur les erreurs dans system.log :

$ grep "com.apple.xpc.launchd" /var/log/system.log  | sed 's/(/ /g' | sed 's/)/ /g' | sed 's/\[/ /g' | awk '{print $7}' | sort -n | uniq -c
   1 com.apple.TMHelperAgent.SetupOffer
   1 com.apple.bsd.dirhelper
   2 com.apple.eospreflightagent
   1 com.apple.preference.notifications.remoteservice
   1 com.apple.preferences.softwareupdate.remoteservice
   1 com.apple.screensharing
   4 com.apple.xpc.launchd.domain.pid.IDECacheDeleteAppExtension.28627
   4 com.apple.xpc.launchd.domain.pid.IDECacheDeleteAppExtension.49501
   1 com.apple.xpc.launchd.domain.pid.mdmclient.52930
   1 com.apple.xpc.launchd.domain.pid.signpost_reporter.27270
   1 com.apple.xpc.launchd.domain.user.501
10854 com.arraynetworks.mhttpd
   1 com.microsoft.OneDrive.FinderSync.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
   1 com.microsoft.OneDrive.FinderSync.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
   1 homebrew.mxcl.prometheus

Le vainqueur est com.arraynetworks.mhttpd … surtout à cause d’une erreur: « Service exited with abnormal code: 3 »

J’ai essayé de faire :

$ launchctl unload com.arraynetworks.mhttpd

Sans succès !

J’ai trouvé finalement :

$ sudo grep "com.arraynetworks.mhttpd" /Library/LaunchAgents/*
/Library/LaunchAgents/com.arraynetworks.mhttpd.plist:	com.arraynetworks.mhttpd

Si je regarde dans le détail :

$ cat /Library/LaunchAgents/com.arraynetworks.mhttpd.plist 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.arraynetworks.mhttpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/motionpro/MotionProHttpd</string>
                <string>-https</string>
                <string>127.0.0.1:60012</string>
                <string>-logfile</string>
                <string>/var/log/MotionPro/MotionProHttpd.log</string>
                <string>-logsize</string>
                <string>10</string>
                <string>-mppath</string>
                <string>/Applications/MotionPro.app/Contents/MacOS</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/motionpro</string>
</dict>
</plist>

Cela plante car le port est déjà en écoute :

$ tail -f /var/log/MotionPro/MotionProHttpd.log 
2019/11/18 15:14:54 send message to 127.0.0.1:65432
2019/11/18 15:14:54 failed to listen tls: listen tcp 127.0.0.1:60012: bind: address already in use
2019/11/18 15:15:04 vpn event monitor start
2019/11/18 15:15:04 vpn event monitor listen address:  127.0.0.1:51359 51359
2019/11/18 15:15:04 send message to 127.0.0.1:65432
2019/11/18 15:15:04 failed to listen tls: listen tcp 127.0.0.1:60012: bind: address already in use
2019/11/18 15:15:14 vpn event monitor start
2019/11/18 15:15:14 vpn event monitor listen address:  127.0.0.1:55185 55185
2019/11/18 15:15:14 send message to 127.0.0.1:65432
2019/11/18 15:15:14 failed to listen tls: listen tcp 127.0.0.1:60012: bind: address already in use

Ce qui est vrai :

$ sudo lsof -iTCP -sTCP:LISTEN -n -P | grep "60012"
aciseagen   583      root   58u  IPv4 0xf99631e60b437f95      0t0  TCP 127.0.0.1:60012 (LISTEN)

J’ai donc arrêter le massacre …

$ launchctl unload /Library/LaunchAgents/com.arraynetworks.mhttpd.plist

Installation de Prometheus sur MacOS

15 x served & 7 x viewed

Ma version de MacOS :

$ uname -a
Darwin MacBook.local 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64

Mise à jours de brew ( en mode verbose afin d’avoir plus d’information ) :

$ brew update -v 
...
$ brew -v
Homebrew 2.1.16
Homebrew/homebrew-core (git revision 00c2c; last commit 2019-11-18)
Homebrew/homebrew-cask (git revision 9e283; last commit 2019-11-18)

Début de l’installation :

$ brew install prometheus
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
mysql-client@5.7
==> Updated Formulae
awsume                       innotop                      manticoresearch              mysql-client                 mytop                        percona-xtrabackup
hydra                        kitchen-sync                 mydumper                     mysql-connector-c++          ntopng                       sysbench
imagemagick                  libzdb                       mysql++                      mysql-connector-c++@1.1      percona-toolkit              vala
==> Deleted Formulae
mysql-connector-c

==> Downloading https://homebrew.bintray.com/bottles/prometheus-2.13.1.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/85/....
############################################################# 100.0%
==> Pouring prometheus-2.13.1.catalina.bottle.tar.gz
==> Caveats
When used with `brew services`, prometheus' configuration is stored as command line flags in
  /usr/local/etc/prometheus.args

Example configuration:
  echo "--config.file ~/.config/prometheus.yml" > /usr/local/etc/prometheus.args


To have launchd start prometheus now and restart at login:
  brew services start prometheus
Or, if you don't want/need a background service you can just run:
  prometheus
==> Summary
🍺  /usr/local/Cellar/prometheus/2.13.1: 18 files, 119.3MB

Lancement du service :

$ echo "--config.file /usr/local/opt/prometheus/prometheus.yml" > /usr/local/etc/prometheus.args
$ vi /usr/local/opt/prometheus/prometheus.yml
$ brew services start prometheus
==> Successfully started `prometheus` (label: homebrew.mxcl.prometheus)

Installation de node_exporter :

$ brew install node_exporter
==> Downloading https://homebrew.bintray.com/bottles/node_exporter-0.18.1_1.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/17/174b28c6400abf9a2c566ea67d0928ad3e49b5a1cf3c1a1b9a813dc19f103094....
######################################################################## 100.0%
==> Pouring node_exporter-0.18.1_1.catalina.bottle.tar.gz
==> Caveats
When used with `brew services`, node_exporter's configuration is stored as command line flags in
  /usr/local/etc/node_exporter.args

Example configuration:
  echo --web.listen-address :9101 > /usr/local/etc/node_exporter.args

For the full list of options, execute
  node_exporter -h

To have launchd start node_exporter now and restart at login:
  brew services start node_exporter
Or, if you don't want/need a background service you can just run:
  node_exporter
==> Summary
🍺  /usr/local/Cellar/node_exporter/0.18.1_1: 8 files, 16MB

$ echo --web.listen-address :9101 > /usr/local/etc/node_exporter.args

$ brew services start node_exporter
==> Successfully started `node_exporter` (label: homebrew.mxcl.node_exporter)

Pour ce connecter : http://0.0.0.0:9090

Installation de Grafana sur MacOS

14 x served & 7 x viewed

Ma version de MacOS :

$ uname -a
Darwin MacBook.local 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64

Mise à jours de brew ( en mode verbose afin d’avoir plus d’information ) :

$ brew update -v 

$ brew -v
Homebrew 2.1.16
Homebrew/homebrew-core (git revision 00c2c; last commit 2019-11-18)
Homebrew/homebrew-cask (git revision 9e283; last commit 2019-11-18)
$ brew install grafana
==> Downloading https://homebrew.bintray.com/bottles/grafana-6.4.4.catalina.bottle.tar.gz

Aie première erreur :

...
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/node/13.1.0: 4,591 files, 54.2MB
==> Installing grafana dependency: yarn
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Error: An exception occurred within a child process:
  CompilerSelectionError: yarn cannot be built with any available compilers.
Install GNU's GCC:
  brew install gcc

Pour fixer le problème :

xcode-select --install

Ensuite, nouvelle installation de gcc :

$ brew install gcc
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
dvc                          node_exporter                rex                          shairport-sync               terraform                    unrar

==> Downloading https://homebrew.bintray.com/bottles/gcc-9.2.0_1.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/e1/e1a6cd0d52fb715431063657cec4e3578170079168b612a6998d321d778330b1
######################################################################## 100.0%
==> Pouring gcc-9.2.0_1.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/gcc/9.2.0_1: 1,462 files, 287.9MB
==> `brew cleanup` has not been run in 30 days, running now...
...

Et pour finir installation de grafana :

$ brew install grafana
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/grafana-6.4.4.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/43/...
#######################################                                   54.9%
curl: (18) transfer closed with 25517176 bytes remaining to read
Error: Failed to download resource "grafana"
Download failed: https://homebrew.bintray.com/bottles/grafana-6.4.4.catalina.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Installing dependencies for grafana: yarn
==> Installing grafana dependency: yarn
==> Downloading https://yarnpkg.com/downloads/1.19.1/yarn-v1.19.1.tar.gz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/...
######################################################################## 100.0%
🍺  /usr/local/Cellar/yarn/1.19.1: 14 files, 5MB, built in 9 seconds
==> Downloading https://github.com/grafana/grafana/archive/v6.4.4.tar.gz
==> Downloading from https://codeload.github.com/grafana/grafana/tar.gz/v6.4.4
######################################################################## 100.0%
==> go run build.go build
==> yarn install --ignore-engines
==> node_modules/grunt-cli/bin/grunt build
==> Caveats
To have launchd start grafana now and restart at login:
  brew services start grafana
Or, if you don't want/need a background service you can just run:
  grafana-server --config=/usr/local/etc/grafana/grafana.ini --homepath /usr/local/share/grafana --packaging=brew cfg:default.paths.logs=/usr/local/var/log/grafana cfg:default.paths.data=/usr/local/var/lib/grafana cfg:default.paths.plugins=/usr/local/var/lib/grafana/plugins
==> Summary
🍺  /usr/local/Cellar/grafana/6.4.4: 3,867 files, 176.6MB, built in 10 minutes 16 seconds
==> Caveats
==> grafana
To have launchd start grafana now and restart at login:
  brew services start grafana
Or, if you don't want/need a background service you can just run:
  grafana-server --config=/usr/local/etc/grafana/grafana.ini --homepath /usr/local/share/grafana --packaging=brew cfg:default.paths.logs=/usr/local/var/log/grafana cfg:default.paths.data=/usr/local/var/lib/grafana cfg:default.paths.plugins=/usr/local/var/lib/grafana/plugins

On lance :

$ brew services start grafana
==> Successfully started `grafana` (label: homebrew.mxcl.grafana )

Ensuite un accès et un changement de login/password ( admin/ admin ):
http://localhost:3000/

Le port par défaut est le 3000 :