Skip to content

Commit 488bc72

Browse files
committed
ok! they match, mostly
1 parent e361252 commit 488bc72

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/shadowbox/server/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ async function main() {
174174
// Start Prometheus subprocess and wait for it to be up and running.
175175
const prometheusConfigFilename = getPersistentFilename('prometheus/config.yml');
176176
const prometheusTsdbFilename = getPersistentFilename('prometheus/data');
177-
const prometheusEndpoint = `http://${prometheusLocation}`;
177+
const prometheusEndpoint = `http://localhost:9095`;
178178
const prometheusBinary = getBinaryFilename('prometheus');
179179
const prometheusArgs = [
180180
'--config.file',

src/shadowbox/server/manager_metrics.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class PrometheusManagerMetrics implements ManagerMetrics {
165165

166166
for (const entryIndex in result.values) {
167167
const [currentTimestamp, nextValue] = result.values[entryIndex];
168-
const [previousTimestamp, currentValue] = bandwidthRangeValues[entryIndex] ?? [0, 0];
168+
const [previousTimestamp, currentValue] = bandwidthRangeValues[entryIndex] ?? [Infinity, 0];
169169

170170
bandwidthRangeValues[entryIndex] = [
171171
Math.min(previousTimestamp, currentTimestamp),
@@ -176,15 +176,18 @@ export class PrometheusManagerMetrics implements ManagerMetrics {
176176

177177
const currentBandwidth = bandwidthRangeValues[bandwidthRangeValues.length - 1] ?? [];
178178

179+
// convert increase() into rate()
180+
serverMetrics.bandwidth.current.data.bytes =
181+
parseFloat(currentBandwidth[1]) / PROMETHEUS_RANGE_QUERY_STEP_SECONDS;
179182
serverMetrics.bandwidth.current.timestamp = currentBandwidth[0];
180-
serverMetrics.bandwidth.current.data.bytes = parseFloat(currentBandwidth[1]);
181183

182184
const peakDataTransferred = findPeak(bandwidthRangeValues);
183185
if (peakDataTransferred !== null) {
184186
const peakValue = parseFloat(peakDataTransferred[1]);
185187

186188
if (peakValue > 0) {
187-
serverMetrics.bandwidth.peak.data.bytes = peakValue;
189+
// convert increase() into rate()
190+
serverMetrics.bandwidth.peak.data.bytes = peakValue / PROMETHEUS_RANGE_QUERY_STEP_SECONDS;
188191
serverMetrics.bandwidth.peak.timestamp = Math.min(now, peakDataTransferred[0]);
189192
}
190193
}

0 commit comments

Comments
 (0)