Skip to content

Commit

Permalink
feat: make metrics retention configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
stfsy committed Jul 18, 2021
1 parent 577f574 commit 7dc35d8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ By default the exporter will start with sensible default values. Configuration c

- --listen.host: `default=127.0.0.1`
- --listen.port `default=127.0.0.1`
- --metrics.retention `default=30000`
- --metrics.endpoint `default=/metrics`
- --metrics.prefix `default=what`
- --metrics.with-timestamp `default=false`
Expand Down
5 changes: 5 additions & 0 deletions lib/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const knownFlags = {
default: '9839',
description: 'the port the exporter user to listen for incoming connections'
},
'--metrics.retention': {
internalName: 'retention',
default: '30000',
description: 'how long to store user sessions before resetting metric value. Should be larger than scrape interval of your Prometheus job.'
},
'--metrics.endpoint': {
internalName: 'endpoint',
default: '/metrics',
Expand Down
4 changes: 3 additions & 1 deletion test/spec/flags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('Flags', () => {
const knownFlags = {
'--listen.host': '123.0.0.1',
'--listen.port': '48123',
'--metrics.retention': '2',
'--metrics.endpoint': '/prometheus',
'--metrics.prefix': 'where',
'--metrics.with-timestamp': 'true',
Expand All @@ -17,6 +18,7 @@ describe('Flags', () => {
const map = {
'--listen.host': 'host',
'--listen.port': 'port',
'--metrics.retention': 'retention',
'--metrics.endpoint': 'endpoint',
'--metrics.prefix': 'prefix',
'--metrics.with-timestamp': 'timestamp',
Expand Down Expand Up @@ -45,7 +47,7 @@ describe('Flags', () => {
return context
}, [])
const result = flags(allFlags)
expect(Object.keys(result)).to.have.length(6)
expect(Object.keys(result)).to.have.length(Object.keys(knownFlags).length)
Object.keys(map).forEach(key => {
expect(result[map[key]]).to.equal(knownFlags[key])
})
Expand Down

0 comments on commit 7dc35d8

Please sign in to comment.