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

イベントサイトのアクセス数を計測する #20

Open
Tracked by #45 ...
oke-py opened this issue Dec 28, 2021 · 8 comments
Open
Tracked by #45 ...

イベントサイトのアクセス数を計測する #20

oke-py opened this issue Dec 28, 2021 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@oke-py
Copy link
Member

oke-py commented Dec 28, 2021

What we want:

It's unclear. We need discussion.

https://event.cloudnativedays.jp/o11y2022

How we do it:

It's unclear. We need discussion.

Anything else:

@oke-py oke-py added the enhancement New feature or request label Dec 28, 2021
@ryojsb ryojsb self-assigned this Dec 29, 2021
@ryojsb
Copy link

ryojsb commented Dec 29, 2021

memo

Option1 [Get access log from envoy with grafana loki]

https://projectcontour.io/docs/v1.18.1/config/access-logging/
https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage

Sample

{job="projectcontour/envoy"} |= "o11y2022"

Result

2021-12-29T08:29:11.414724453Z stdout F [2021-12-29T08:29:10.103Z] "GET /o11y2022 HTTP/2" 200 - 0 4566 39 38 "10.0.91.251" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15" "59f35b29-e269-4f86-9eb5-077dd4073853" "event.cloudnativedays.jp" "10.0.168.57:3000"

Consideration

以下のようなものも含むのか、それとも純粋にGET /o11y2022のみを対象とするか。

GET /o11y2022/speakers/entry?****
GET /o11y2022/talks

これらは、/o11y2022 にアクセスした上でたどり着くパスである可能性が高いため、アクセス数として換算すると重複するのではないかという点について確認したい。

Option2 [Google Analytics]

Google Analyticsを用いて解析し、APIからデータを取得する。
(可能かは未確認)

https://support.google.com/analytics/answer/1008004?hl=ja

Option3 [AWS CloudWatch]

https://docs.aws.amazon.com/ja_jp/elasticloadbalancing/latest/network/load-balancer-cloudwatch-metrics.html
https://docs.aws.amazon.com/ja_jp/elasticloadbalancing/latest/network/load-balancer-access-logs.html

上記は、NLBがL4のため、L7の解析は難しそう。

https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/Container-Insights-setup-EKS-quickstart.html
https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/Container-Insights-setup-logs-FluentBit.html

上記のように、CloudWatch Logsを使用するためにFluent bitを使用することで、アクセス解析ができそう。

Consideration

CloudWatchの料金の関係等もあるので、Grafanaで補えるのであればそれで良さそう。

@riita10069
Copy link
Member

これってCloud Watch で取れてないんですかね?
UAが取れないとかですか?

@ryojsb
Copy link

ryojsb commented Dec 29, 2021

ありがとうございます!

It's unclear. We need discussion.

とあるので、一旦そこまで時間をかけずにブレスト的に洗い出してました。

CloudWatchで結構簡単に取れそうですか?
(ELBのメトリックとか?)

@riita10069
Copy link
Member

CloudWatchで結構簡単に取れそうですか?

まだ調査はしてないので、これも思いつきで言ってみた程度です!

ELBのメトリックとか?

そうですね!amazon側のfluentdのdaemonsetからPodのログとか取れてる気もするので、
UAでBot弾けば、どのユーザーがどんな遷移してるかって取れるかなぁと思った感じです。

@ryojsb
Copy link

ryojsb commented Dec 29, 2021

ありがとうございます、とても助かります!
この辺り、見れそうか確認してみます!

@ryojsb
Copy link

ryojsb commented Jan 26, 2022

一度、Grafana Lokiの情報を元に、Grafana上でグラフを作成しました。
https://grafana.cloudnativedays.jp/d/uQz8C317k/access-count-ry?orgId=1

現状、以下のグラフを作成しています。

  • Total Access数
  • 失敗したAccess数
  • Total Access数 (Pod単位)
  • Total Access log
  • 失敗した Access log

@iaoiui iaoiui added this to the o11y2022 milestone Jan 28, 2022
@ryojsb
Copy link

ryojsb commented Feb 6, 2022

備忘: ログは何日保管しているのか。どこで設定しているのか。

ポリシーが適用されてないため、以下を元に恐らく永久的にLogを保管し続けるのではないかなと思います。

  1. 設定がされていない。
  2. 実機でのLogが保持されている日数

1. 設定がされていない。

まず、lokiの設定は/etc/loki/loki.yamlでされています。

$ cat /etc/loki/loki.yaml
auth_enabled: false
chunk_store_config:
  max_look_back_period: 0s
compactor:
  shared_store: filesystem
  working_directory: /data/loki/boltdb-shipper-compactor
ingester:
  chunk_block_size: 262144
  chunk_idle_period: 3m
  chunk_retain_period: 1m
  lifecycler:
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
  max_transfer_retries: 0
limits_config:
  enforce_metric_name: false
  reject_old_samples: true
  reject_old_samples_max_age: 168h
schema_config:
  configs:
  - from: “2020-10-24”
    index:
      period: 24h
      prefix: index_
    object_store: filesystem
    schema: v11
    store: boltdb-shipper
server:
  http_listen_port: 3100
storage_config:
  boltdb_shipper:
    active_index_directory: /data/loki/boltdb-shipper-active
    cache_location: /data/loki/boltdb-shipper-cache
    cache_ttl: 24h
    shared_store: filesystem
  filesystem:
    directory: /data/loki/chunks
table_manager:
  retention_deletes_enabled: false
  retention_period: 0s

Logを保持するには、Compactorで有効にするか、table_managerで有効にするかの2択になっていて、
まず、table_managerのretention_delete_enabledはfalseになっているので、table_managerでの保持はされません。

次にCompactorですが、ファイル上では指定されていません。
以下が設定におけるデフォルト値です。

  • compactor
# (Experimental) Activate custom (per-stream,per-tenant) retention.
# CLI flag: -boltdb.shipper.compactor.retention-enabled
[retention_enabled: <boolean> | default = false]
  • limits_config
# Retention to apply for the store, if the retention is enable on the compactor side.
# CLI flag: -store.retention
[retention_period: <duration> | default = 744h]

2. 実機でのLogが保持されている日数

実機を確認すると、データを取得し始めた時期と一致します。
よってLog自体は消されていないと考えられる。

  • data in loki
$ ls -l /data/loki/boltdb-shipper-compactor/
total 0
drwxrwsr-x    2 loki     loki             6 Nov 28 03:15 index_18958
drwxrwsr-x    2 loki     loki             6 Nov 29 03:15 index_18959
drwxrwsr-x    2 loki     loki             6 Nov 30 03:15 index_18960
drwxrwsr-x    2 loki     loki             6 Dec  1 03:15 index_18961
drwxrwsr-x    2 loki     loki             6 Dec  2 03:15 index_18962
drwxrwsr-x    2 loki     loki             6 Dec  3 03:15 index_18963
drwxrwsr-x    2 loki     loki             6 Dec  4 03:15 index_18964
drwxrwsr-x    2 loki     loki             6 Dec  5 03:15 index_18965
drwxrwsr-x    2 loki     loki             6 Dec  6 03:15 index_18966
drwxrwsr-x    2 loki     loki             6 Dec  7 03:15 index_18967
drwxrwsr-x    2 loki     loki             6 Dec  8 03:15 index_18968
drwxrwsr-x    2 loki     loki             6 Dec  9 03:15 index_18969
drwxrwsr-x    2 loki     loki             6 Dec 10 03:15 index_18970
drwxrwsr-x    2 loki     loki             6 Dec 11 03:15 index_18971
drwxrwsr-x    2 loki     loki             6 Dec 12 03:15 index_18972
drwxrwsr-x    2 loki     loki             6 Dec 13 03:15 index_18973
drwxrwsr-x    2 loki     loki             6 Dec 14 03:15 index_18974
drwxrwsr-x    2 loki     loki             6 Dec 15 02:42 index_18975
drwxrwsr-x    2 loki     loki             6 Dec 16 02:42 index_18976
drwxrwsr-x    2 loki     loki             6 Dec 17 02:42 index_18977
drwxrwsr-x    2 loki     loki             6 Dec 18 02:42 index_18978
drwxrwsr-x    2 loki     loki             6 Dec 19 02:42 index_18979
drwxrwsr-x    2 loki     loki             6 Dec 20 02:42 index_18980
drwxrwsr-x    2 loki     loki             6 Dec 21 04:42 index_18981
drwxrwsr-x    2 loki     loki             6 Dec 22 02:42 index_18982
drwxrwsr-x    2 loki     loki             6 Dec 23 02:42 index_18983
drwxrwsr-x    2 loki     loki             6 Dec 24 02:42 index_18984
drwxrwsr-x    2 loki     loki             6 Dec 25 02:42 index_18985
drwxrwsr-x    2 loki     loki             6 Dec 26 04:42 index_18986
drwxrwsr-x    2 loki     loki             6 Dec 27 02:42 index_18987
drwxrwsr-x    2 loki     loki             6 Dec 28 02:42 index_18988
drwxrwsr-x    2 loki     loki             6 Dec 29 02:42 index_18989
drwxrwsr-x    2 loki     loki             6 Dec 30 02:42 index_18990
drwxrwsr-x    2 loki     loki             6 Dec 31 04:42 index_18991
drwxrwsr-x    2 loki     loki             6 Jan  1 02:42 index_18992
drwxrwsr-x    2 loki     loki             6 Jan  2 02:42 index_18993
drwxrwsr-x    2 loki     loki             6 Jan  3 02:42 index_18994
drwxrwsr-x    2 loki     loki             6 Jan  4 02:42 index_18995
drwxrwsr-x    2 loki     loki             6 Jan  5 04:42 index_18996
drwxrwsr-x    2 loki     loki             6 Jan  6 02:42 index_18997
drwxrwsr-x    2 loki     loki             6 Jan  7 02:42 index_18998
drwxrwsr-x    2 loki     loki             6 Jan  8 02:42 index_18999
drwxrwsr-x    2 loki     loki             6 Jan  9 02:42 index_19000
drwxrwsr-x    2 loki     loki             6 Jan 10 02:42 index_19001
drwxrwsr-x    2 loki     loki             6 Jan 11 02:42 index_19002
drwxrwsr-x    2 loki     loki             6 Jan 12 02:42 index_19003
drwxrwsr-x    2 loki     loki             6 Jan 13 02:42 index_19004
drwxrwsr-x    2 loki     loki             6 Jan 14 02:42 index_19005
drwxrwsr-x    2 loki     loki             6 Jan 15 02:41 index_19006
drwxrwsr-x    2 loki     loki             6 Jan 16 02:41 index_19007
drwxrwsr-x    2 loki     loki             6 Jan 17 02:41 index_19008
drwxrwsr-x    2 loki     loki             6 Jan 18 02:41 index_19009
drwxrwsr-x    2 loki     loki             6 Jan 19 02:41 index_19010
drwxrwsr-x    2 loki     loki             6 Jan 20 02:41 index_19011
drwxrwsr-x    2 loki     loki             6 Jan 21 04:10 index_19012
drwxrwsr-x    2 loki     loki             6 Jan 22 04:10 index_19013
drwxrwsr-x    2 loki     loki             6 Jan 23 04:10 index_19014
drwxrwsr-x    2 loki     loki             6 Jan 24 02:42 index_19015
drwxr-sr-x    2 loki     loki             6 Jan 25 04:09 index_19016
drwxr-sr-x    2 loki     loki             6 Jan 26 04:09 index_19017
drwxr-sr-x    2 loki     loki             6 Jan 27 04:09 index_19018
drwxr-sr-x    2 loki     loki             6 Jan 28 04:09 index_19019
drwxr-sr-x    2 loki     loki             6 Jan 29 04:09 index_19020
drwxr-sr-x    2 loki     loki             6 Jan 30 04:09 index_19021
drwxr-sr-x    2 loki     loki             6 Jan 31 04:09 index_19022
drwxr-sr-x    2 loki     loki             6 Feb  1 04:09 index_19023
drwxr-sr-x    2 loki     loki             6 Feb  2 04:09 index_19024
drwxr-sr-x    2 loki     loki             6 Feb  3 04:09 index_19025
drwxr-sr-x    2 loki     loki             6 Feb  4 04:09 index_19026
drwxr-sr-x    2 loki     loki             6 Feb  5 04:09 index_19027
drwxr-sr-x    2 loki     loki             6 Feb  6 04:09 index_19028
  • PVC
% kubectl get pvc -n monitoring |grep loki
storage-loki-0                                Bound    pvc-44becd6e-393f-42db-bc3b-b62c331ed864   10Gi       RWO            ebs-sc         71d

@oke-py
Copy link
Member Author

oke-py commented Feb 24, 2022

動画配信の視聴者数は #21 で扱う。
こちらはトップページ、タイムテーブル、セッション詳細などの静的コンテンツのアクセス数を計測するものと解釈した。
次回以降に持ち越し。

@iaoiui iaoiui modified the milestones: o11y2022, o11y2022以降 Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants