No description
Find a file
2023-08-14 14:34:07 +12:00
cmd/gomastodonstats Add second 2023-05-24 20:55:13 +12:00
dist Add systemd timer/service + update readme 2023-01-30 13:04:12 +13:00
internal/gomastodonstats hotfix calckey 2023-08-14 14:34:07 +12:00
.env.example Test adding MySQL 2023-05-08 22:59:39 +12:00
.gitignore Initial Commit 2023-01-30 10:56:54 +13:00
go.mod Test adding MySQL 2023-05-08 22:59:39 +12:00
go.sum Test adding MySQL 2023-05-08 22:59:39 +12:00
README.md Test adding MySQL 2023-05-08 22:59:39 +12:00
test.go Log 2023-02-13 08:22:12 +13:00

go-mastodon-stats

Pulls in a bunch of stats from services, sends to a statsdb schema and posts to matrix/mastodon weekly.

Setup a new application, use the ID/SECRET in your .env with some user creds

https://mastodon.nz/settings/applications/new

Create readonly account with access to stats DB on postgres

CREATE USER gomastodonstats WITH PASSWORD 'superrandompassword';

\c pixelfed
GRANT SELECT ON ALL TABLES IN SCHEMA public TO gomastodonstats;

\c mtrx
GRANT SELECT ON ALL TABLES IN SCHEMA public TO gomastodonstats;

\c mastodon_production
GRANT SELECT ON ALL TABLES IN SCHEMA public TO gomastodonstats;

\c peertube_prod
GRANT SELECT ON ALL TABLES IN SCHEMA public TO gomastodonstats;

\c mobilizon_prod
GRANT SELECT ON ALL TABLES IN SCHEMA public TO gomastodonstats;

CREATE DATABASE gomastodonstats WITH OWNER gomastodonstats;

\c gomastodonstats
CREATE TABLE IF NOT EXISTS statsdb (
	id SERIAL,
	service VARCHAR(50) NOT NULL,
	metric_name VARCHAR(50) NOT NULL,
    metric_time TIMESTAMPTZ NOT NULL,
	metric_value INT NOT NULL,
    PRIMARY KEY (id)
);
CREATE UNIQUE INDEX service_lookup ON statsdb USING btree (service,metric_name, metric_time);

GRANT ALL ON ALL TABLES IN SCHEMA public TO gomastodonstats;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO gomastodonstats;

For write.as stats on MySQL

create user gomastodonstats@'%' identified by '<pass>';
grant SELECT on writeasdb.* to 'gomastodonstats';