SignalFxで、kubernetesのモニタリングをやってみた

#SignalFxでk8sのモニタリングをしてみよう
前回は、awsのモニタリングをやってみたので、今回はk8sのmonitoringをやってみます。
事前に、k8sの環境は構築済みです。

ドキュメントは下記にあります。

https://docs.signalfx.com/en/latest/integrations/kubernetes/k8s-quick-install.html

なおSignalFxをk8sで使う場合には、helmを使ってインストールを行うので、事前にhelmのインストールが必要です。

## repo の追加 と update
```bash
[sokayama@sokayama-mbp-58037]# helm repo add signalfx https://dl.signalfx.com/helm-repo
"signalfx" has been added to your repositories
[sokayama@sokayama-mbp-58037]#
[sokayama@sokayama-mbp-58037] # helm repo update
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "signalfx" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete.
[sokayama@sokayama-mbp-58037] #
```

## SignalFxへの設定
- AccessTokenはSignalFxのAccessToken(MyProfileから確認)
- clusterNameはk8sのcluster
- signalFxRealmは、SignalFxのRealmを入力

下記を実行すると、podやら各種もろもろが作成される。


```bash
[sokayama@sokayama-mbp-58037] # helm install --set signalFxAccessToken=XXXXXXXXXXXXX --set clusterName=sokayama3.cluster.k8s.local --set agentVersion=4.13.0 --set signalFxRealm=XXX signalfx/signalfx-agent
NAME:   iced-cat
LAST DEPLOYED: Tue Nov  5 23:39:39 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/ConfigMap
NAME                     DATA  AGE
iced-cat-signalfx-agent  1     0s

==> v1/DaemonSet
NAME                     DESIRED  CURRENT  READY  UP-TO-DATE  AVAILABLE  NODE SELECTOR  AGE
iced-cat-signalfx-agent  3        3        0      3           0          <none>         0s

==> v1/Pod(related)
NAME                           READY  STATUS             RESTARTS  AGE
iced-cat-signalfx-agent-8fsfj  0/1    ContainerCreating  0         0s
iced-cat-signalfx-agent-b8q6s  0/1    ContainerCreating  0         0s
iced-cat-signalfx-agent-sss4c  0/1    ContainerCreating  0         0s

==> v1/Secret
NAME                     TYPE    DATA  AGE
iced-cat-signalfx-agent  Opaque  1     0s

==> v1/ServiceAccount
NAME                     SECRETS  AGE
iced-cat-signalfx-agent  1        0s

==> v1beta1/ClusterRole
NAME                     AGE
iced-cat-signalfx-agent  0s

==> v1beta1/ClusterRoleBinding
NAME                     AGE
iced-cat-signalfx-agent  0s


NOTES:
The SignalFx agent is being deployed in your Kubernetes cluster.  You should
see metrics flowing once the agent image is downloaded and started (this may
take a few minutes since it has to download the agent container image).

Assuming you are logged into SignalFx in your browser, visit

https://app.ap0.signalfx.com/#/navigator/kubernetes%20pods/kubernetes%20pods

to see all of the pods in your cluster.

[sokayama@sokayama-mbp-58037] #
```

##Podを確認
iced-cat-singalfxのpodが作成されていることを確認

```bash
[sokayama@sokayama-mbp-58037] # kubectl get pods
NAME                                        READY   STATUS    RESTARTS   AGE
iced-cat-signalfx-agent-8fsfj               1/1     Running   0          3m54s
iced-cat-signalfx-agent-b8q6s               1/1     Running   0          3m54s
iced-cat-signalfx-agent-sss4c               1/1     Running   0          3m54s
nuanced-anaconda-mongodb-596b458774-mjvgk   1/1     Running   0          15m
[sokayama@sokayama-mbp-58037] #
```

##Dashboardを確認してみる。
手順的には以上で、しばらくするとSignalFxのDashboardにk8sの画面が下記のようにでてくる。

<img width="238" alt="Screen Shot 2019-11-05 at 11.48.16 PM.jpg" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/190656/45abe8f9-5c85-0414-dc5b-5011c189dad2.jpeg">

いくつか抜粋してみてみると、

###k8s overviewはこんな感じ

<img width="1669" alt="Screen Shot 2019-11-05 at 11.54.08 PM.jpg" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/190656/95fd21cf-7d25-7470-80d3-2bd4912782b5.jpeg">

###k8sのNodeはこんな感じ


<img width="1680" alt="Screen Shot 2019-11-05 at 11.49.43 PM.jpg" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/190656/7c812ebd-b391-0168-2699-8e7e67a473d1.jpeg">

### containerはこんな感じ
10s単位でモニタリングしてる。

<img width="1680" alt="Screen Shot 2019-11-05 at 11.50.17 PM.jpg" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/190656/804a4102-e648-89cd-97de-053f661c1050.jpeg">

##おわりに
helmで1stepで構築できるので、これはめっちゃ便利かな。