Skip to content

Commit 700b15a

Browse files
committed
Report api key as value
1 parent 4bd5fb2 commit 700b15a

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ Add generated API token to Github secrets as `CLOUDFLARE_API_TOKEN` and authenti
3434
Other required environment variables include the following:
3535
- `INFLUX_URL` - InfluxDB URL
3636
- `INFLUX_DATABASE` - InfluxDB database (bucket) name
37-
- `INFLUX_METRIC_NAME` - InfluxDB metric name
38-
- `REQUEST_URL` - URL of the application where requests are proxied to
37+
- `INFLUX_METRIC_NAME` - InfluxDB metric name

bin/worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
caches.default.put(request, response.clone())
88
)
99
ctx.waitUntil(
10-
reportMetric(request, response.headers, env)
10+
reportMetric(request, env)
1111
);
1212
return response;
1313
}

lib/influx.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const reportMetric = async (request, env) => {
66
// Define API endpoint and headers
77
const url = `${env.INFLUX_URL}/api/v2/write?&bucket=${env.INFLUX_DATABASE}&precision=ms`;
88

9-
await fetch(url, {
9+
return fetch(url, {
1010
method: 'POST',
1111
headers: {
1212
'Authorization': `Token ${env.INFLUX_TOKEN}`,
@@ -31,5 +31,5 @@ export const createMetricsFromRequest = (request, env) => {
3131
);
3232

3333
// We're setting field value to 1 to count the number of requests
34-
return `${env.INFLUX_METRIC_NAME},api_key="${apiKey}" value=1 ${timestamp}`
34+
return `${env.INFLUX_METRIC_NAME} api_key="${apiKey}" ${timestamp}`
3535
}

0 commit comments

Comments
 (0)