mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-10-24 21:41:16 +00:00
Merge pull request #296 from Jigsaw-Code/fortuna-fix
Fix reported metrics
This commit is contained in:
commit
40ba2ef12d
2 changed files with 7 additions and 2 deletions
|
|
@ -28,6 +28,9 @@ export class PrometheusManagerMetrics implements ManagerMetrics {
|
|||
|
||||
async get30DayByteTransfer(): Promise<DataUsageByUser> {
|
||||
// TODO(fortuna): Consider pre-computing this to save server's CPU.
|
||||
// We measure only traffic leaving the server, since that's what DigitalOcean charges.
|
||||
// TODO: Display all directions to admin
|
||||
// TODO: Remove >p< once ss-libev support is gone.
|
||||
const result = await this.prometheusClient.query(
|
||||
'sum(increase(shadowsocks_data_bytes{dir=~"c<p|p>t|>p<"}[30d])) by (access_key)');
|
||||
const usage = {} as {[userId: string]: number};
|
||||
|
|
|
|||
|
|
@ -74,8 +74,10 @@ export class PrometheusUsageMetrics implements UsageMetrics {
|
|||
|
||||
async getUsage(): Promise<KeyUsage[]> {
|
||||
const timeDeltaSecs = Math.round((Date.now() - this.resetTimeMs) / 1000);
|
||||
const result =
|
||||
await this.prometheusClient.query(`sum(increase(shadowsocks_data_bytes{dir=">p<"}[${
|
||||
// We measure the traffic to and from the target, since that's what we are protecting.
|
||||
// TODO: remove >p< once the ss-libev support is gone.
|
||||
const result = await this.prometheusClient.query(
|
||||
`sum(increase(shadowsocks_data_bytes{dir=~">p<|p>t|p<t"}[${
|
||||
timeDeltaSecs}s])) by (location, access_key)`);
|
||||
const usage = [] as KeyUsage[];
|
||||
for (const entry of result.result) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue