mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-05-13 13:58:57 +00:00
feedback
This commit is contained in:
parent
9b8b4d07c2
commit
6a39bec6f6
3 changed files with 42 additions and 10 deletions
|
|
@ -418,6 +418,35 @@ paths:
|
|||
examples:
|
||||
'0':
|
||||
value: '{"bytesTransferredByUserId":{"1":1008040941,"2":5958113497,"3":752221577}}'
|
||||
/metrics/tunnel-time-location
|
||||
get:
|
||||
description: Returns the tunnel time per location
|
||||
tags:
|
||||
- Tunnel time
|
||||
responses:
|
||||
'200':
|
||||
description: The tunnel time per location
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
location:
|
||||
type: string
|
||||
asn:
|
||||
type: number
|
||||
as_org:
|
||||
type: string
|
||||
tunnel_time:
|
||||
type: object
|
||||
properties:
|
||||
seconds:
|
||||
type: number
|
||||
examples:
|
||||
'0':
|
||||
value: '[{"location":"US","asn":7922,"as_org":"Comcast Cable Communications, LLC","tunnel_time":{"seconds":2523432}]'
|
||||
/metrics/enabled:
|
||||
get:
|
||||
description: Returns whether metrics is being shared
|
||||
|
|
|
|||
|
|
@ -15,24 +15,26 @@
|
|||
import {PrometheusClient} from '../infrastructure/prometheus_scraper';
|
||||
import {DataUsageByUser, DataUsageTimeframe} from '../model/metrics';
|
||||
|
||||
interface TunnelTimeDuration {
|
||||
interface Duration {
|
||||
seconds: number;
|
||||
}
|
||||
|
||||
interface TunnelTimeRequest {
|
||||
time_window: TunnelTimeDuration;
|
||||
time_window: Duration;
|
||||
}
|
||||
|
||||
interface TunnelTimeResponse {
|
||||
interface TunnelTimeResponseEntry {
|
||||
location?: string;
|
||||
asn?: number;
|
||||
as_org?: string;
|
||||
tunnel_time: TunnelTimeDuration;
|
||||
tunnel_time: Duration;
|
||||
}
|
||||
|
||||
type TunnelTimeResponse = TunnelTimeResponseEntry[];
|
||||
|
||||
export interface ManagerMetrics {
|
||||
getOutboundByteTransfer(timeframe: DataUsageTimeframe): Promise<DataUsageByUser>;
|
||||
getTunnelTimeByLocation(request: TunnelTimeRequest): Promise<TunnelTimeResponse[]>;
|
||||
getTunnelTimeByLocation(request: TunnelTimeRequest): Promise<TunnelTimeResponse>;
|
||||
}
|
||||
|
||||
// Reads manager metrics from a Prometheus instance.
|
||||
|
|
@ -57,11 +59,9 @@ export class PrometheusManagerMetrics implements ManagerMetrics {
|
|||
return {bytesTransferredByUserId: usage};
|
||||
}
|
||||
|
||||
async getTunnelTimeByLocation({
|
||||
time_window: {seconds},
|
||||
}: TunnelTimeRequest): Promise<TunnelTimeResponse[]> {
|
||||
async getTunnelTimeByLocation(request: TunnelTimeRequest): Promise<TunnelTimeResponse> {
|
||||
const {result} = await this.prometheusClient.query(
|
||||
`sum(increase(shadowsocks_tunnel_time_seconds_per_location[${seconds}s])) by (location, asn, asorg)`
|
||||
`sum(increase(shadowsocks_tunnel_time_seconds_per_location[${request.time_window.seconds}s])) by (location, asn, asorg)`
|
||||
);
|
||||
|
||||
return result.map((entry) => ({
|
||||
|
|
|
|||
|
|
@ -157,7 +157,10 @@ export function bindService(
|
|||
);
|
||||
|
||||
apiServer.get(`${apiPrefix}/metrics/transfer`, service.getDataUsage.bind(service));
|
||||
apiServer.get(`${apiPrefix}/metrics/tunnel-time`, service.getTunnelTimeByLocation.bind(service));
|
||||
apiServer.get(
|
||||
`${apiPrefix}/metrics/tunnel-time-location`,
|
||||
service.getTunnelTimeByLocation.bind(service)
|
||||
);
|
||||
apiServer.get(`${apiPrefix}/metrics/enabled`, service.getShareMetrics.bind(service));
|
||||
apiServer.put(`${apiPrefix}/metrics/enabled`, service.setShareMetrics.bind(service));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue