-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7dc0254
commit 2de32a9
Showing
18 changed files
with
723 additions
and
512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "s3-prometheus-exporter", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "S3 data exporter for prometheus", | ||
"author": "Tchoupinax <[email protected]> (https://corentinfiloche.xyz)", | ||
"license": "MIT", | ||
|
@@ -21,7 +21,7 @@ | |
"watch": "nodemon --exec vite-node --options.deps.inline=\"@aws-sdk\" src/index.ts" | ||
}, | ||
"dependencies": { | ||
"@aws-sdk/client-s3": "3.395.0", | ||
"@aws-sdk/client-s3": "3.398.0", | ||
"config": "3.3.9", | ||
"express": "4.18.2", | ||
"fastify": "4.21.0", | ||
|
@@ -30,13 +30,13 @@ | |
"pino-pretty": "10.2.0", | ||
"pretty-bytes": "6.1.1", | ||
"prom-client": "14.2.0", | ||
"vite-node": "0.34.2", | ||
"vitest": "0.34.2" | ||
"vite-node": "0.34.3", | ||
"vitest": "0.34.3" | ||
}, | ||
"devDependencies": { | ||
"@types/config": "3.3.0", | ||
"@types/express": "4.17.17", | ||
"@types/node": "20.5.1", | ||
"@types/node": "20.5.6", | ||
"esbuild-plugin-tsc": "0.4.0", | ||
"eslint-config-tchoupinax": "1.0.3", | ||
"nodemon": "3.0.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { _Object } from "@aws-sdk/client-s3"; | ||
import { Gauge, Registry } from "prom-client"; | ||
|
||
import { Metric } from "../metric"; | ||
|
||
export default class extends Metric { | ||
constructor () { | ||
super("biggest_file_size", "global"); | ||
} | ||
|
||
declarePrometheusMesure (register: Registry): Gauge<any> { | ||
return new Gauge({ | ||
name: this.name(), | ||
help: "Biggest file size", | ||
labelNames: ["name"], | ||
registers: [register], | ||
}); | ||
} | ||
|
||
process (files: _Object[]): number { | ||
return files.reduce((acc: number, cur: _Object) => { | ||
if (cur.Size && acc < cur.Size) { | ||
return cur.Size; | ||
} else { | ||
return acc; | ||
} | ||
}, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { _Object } from "@aws-sdk/client-s3"; | ||
import { Gauge, Registry } from "prom-client"; | ||
|
||
import { Metric } from "./../metric"; | ||
|
||
export default class extends Metric { | ||
constructor () { | ||
super("files_count", "global"); | ||
} | ||
|
||
declarePrometheusMesure (register: Registry): Gauge<any> { | ||
return new Gauge({ | ||
name: this.name(), | ||
help: "Count of files in the bucket", | ||
labelNames: ["name"], | ||
registers: [register], | ||
}); | ||
} | ||
|
||
process (files: _Object[]): number { | ||
return files.length; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { _Object } from "@aws-sdk/client-s3"; | ||
import { Gauge, Registry } from "prom-client"; | ||
|
||
import { Metric } from "../metric"; | ||
|
||
export default class extends Metric { | ||
constructor () { | ||
super("smallest_file_size", "global"); | ||
} | ||
|
||
declarePrometheusMesure (register: Registry): Gauge<any> { | ||
return new Gauge({ | ||
name: this.name(), | ||
help: "Smallest file size", | ||
labelNames: ["name"], | ||
registers: [register], | ||
}); | ||
} | ||
|
||
process (files: Array<_Object>): number { | ||
return files.reduce((acc: number, cur: _Object) => { | ||
if (cur.Size && acc < cur.Size) { | ||
return cur.Size ?? 0; | ||
} else { | ||
return acc; | ||
} | ||
}, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/metrics/metric-biggest-file-size.ts → ...rics/prefixed/metric-biggest-file-size.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/metrics/metric-latest-file-size.ts → ...trics/prefixed/metric-latest-file-size.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/metrics/metric-latest-file-timestamp.ts → .../prefixed/metric-latest-file-timestamp.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/metrics/metric-oldest-file-timestamp.ts → .../prefixed/metric-oldest-file-timestamp.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/metrics/metric-smallest-file-size.ts → ...ics/prefixed/metric-smallest-file-size.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.