Skip to content

Commit

Permalink
feat: calculate the size of the bucket (#13)
Browse files Browse the repository at this point in the history
* feat: calculate the size of the bucket

* chore: upgrade deps

* chore: prepare v0.0.4
  • Loading branch information
Tchoupinax authored Dec 26, 2023
1 parent 9035a63 commit 5c0c466
Show file tree
Hide file tree
Showing 5 changed files with 904 additions and 795 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.4.0 | 2023-12-26

#### Features

- Add metric to calculate the size of a bucket

#### Chores

- Upgrade dependencies

## 0.3.0 | 2023-08-25

#### Features
Expand Down
2 changes: 1 addition & 1 deletion config/default.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"accessKey": "minio",
"bucket": "minio",
"endpoint": "http://s3.fr-par.scw.cloud",
"endpoint": "https://s3.fr-par.scw.cloud",
"logger": {
"level": "debug",
"pretty": true
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s3-prometheus-exporter",
"version": "0.3.0",
"version": "0.4.0",
"description": "S3 data exporter for prometheus",
"author": "Tchoupinax <[email protected]> (https://corentinfiloche.xyz)",
"license": "MIT",
Expand All @@ -21,25 +21,25 @@
"watch": "nodemon --exec vite-node --options.deps.inline=\"@aws-sdk\" src/index.ts"
},
"dependencies": {
"@aws-sdk/client-s3": "3.456.0",
"@aws-sdk/client-s3": "3.478.0",
"config": "3.3.9",
"express": "4.18.2",
"fastify": "4.24.3",
"fastify": "4.25.2",
"moment": "2.29.4",
"pino": "8.16.2",
"pino-pretty": "10.2.3",
"pino": "8.17.1",
"pino-pretty": "10.3.0",
"pretty-bytes": "6.1.1",
"prom-client": "15.0.0",
"vite-node": "0.34.6",
"vitest": "0.34.6"
"prom-client": "15.1.0",
"vite-node": "1.1.0",
"vitest": "1.1.0"
},
"devDependencies": {
"@types/config": "3.3.3",
"@types/express": "4.17.21",
"@types/node": "20.10.0",
"@types/node": "20.10.5",
"esbuild-plugin-tsc": "0.4.0",
"eslint-config-tchoupinax": "1.0.3",
"nodemon": "3.0.1",
"nodemon": "3.0.2",
"typescript": "5"
}
}
25 changes: 25 additions & 0 deletions src/metrics/global/metric-bucket-size.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { _Object } from "@aws-sdk/client-s3";
import { Gauge, Registry } from "prom-client";

import { Metric } from "../metric";

export default class extends Metric {
constructor () {
super("bucket_size", "global");
}

declarePrometheusMesure (register: Registry): Gauge<any> {
return new Gauge({
name: this.name(),
help: "Size of the bucket (in Bytes)",
labelNames: ["name"],
registers: [register],
});
}

process (files: _Object[]): number {
return files.reduce((acc: number, cur: _Object) => {
return cur.Size! + acc;
}, 0);
}
}
Loading

0 comments on commit 5c0c466

Please sign in to comment.