-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
48 lines (43 loc) · 2.16 KB
/
stats.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Stats
on:
repository_dispatch:
workflow_dispatch:
# Disable cron for now as we have not migrated our analytics yet
# schedule:
# - cron: "00 22 * * *"
jobs:
stats:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GH_STATS_COMMIT_TOKEN }}
- name: Install logcli
run: |
rm -rf logcli.zip logcli-linux-amd64
wget -nc -q -O "logcli.zip" "https://github.com/grafana/loki/releases/download/v2.4.2/logcli-linux-amd64.zip"
unzip logcli.zip
chmod a+x logcli-linux-amd64
- name: Run logcli
run: |
mkdir -p data/api/stats/
./logcli-linux-amd64 -q --org-id=${ORG_ID} instant-query 'topk(25, sum(count_over_time({path=~"/tool/.*"}[7d])) by (path))' > data/api/stats_tools_raw.json
cat data/api/stats_tools_raw.json | jq '[.[] | {(.metric.path | sub("^\/tool\/"; "")): (.value[1]|tonumber) }] | add' > data/api/stats/tools_unsorted.json
cat data/api/stats/tools_unsorted.json | jq 'to_entries | sort_by(.value) | reverse | from_entries' > data/api/stats/tools.json
rm data/api/stats/tools_unsorted.json
rm data/api/stats_tools_raw.json
./logcli-linux-amd64 -q --org-id=${ORG_ID} instant-query 'topk(25, sum(count_over_time({path=~"/tag/.*"}[7d])) by (path))' > data/api/stats_tags_raw.json
cat data/api/stats_tags_raw.json | jq '[.[] | {(.metric.path | sub("^\/tool\/"; "")): (.value[1]|tonumber) }] | add' > data/api/stats/tags_unsorted.json
cat data/api/stats/tags_unsorted.json | jq 'to_entries | sort_by(.value) | reverse | from_entries' > data/api/stats/tags.json
rm data/api/stats/tags_unsorted.json
rm data/api/stats_tags_raw.json
env:
ORG_ID: ${{secrets.LOKI_ORG_ID}}
LOKI_ADDR: http://loki.jorgelbg.me
- uses: stefanzweifel/[email protected]
with:
branch: ${{ github.head_ref }}
commit_message: Commit list
commit_user_name: Analysis Tools Bot
commit_user_email: [email protected]
commit_author: Analysis Tools Bot <[email protected]>