-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added: display last db update whenever trivy server is started
- Loading branch information
1 parent
e08ae8d
commit d47148b
Showing
6 changed files
with
152 additions
and
17 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package extendedconfig | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
"github.com/aquasecurity/trivy/internal/server/config" | ||
) | ||
|
||
// ExtendedConfig represents prometheus-related configuration alongside the provided config.Config | ||
type ExtendedConfig struct { | ||
Config config.Config | ||
MetricsRegistry *prometheus.Registry | ||
GaugeMetric *prometheus.GaugeVec | ||
} | ||
|
||
// New bootstraps an ExtendedConfig object out of a config.Config object for further operation | ||
func New(c config.Config) ExtendedConfig { | ||
return ExtendedConfig{ | ||
Config: c, | ||
} | ||
} | ||
|
||
// Init populates the relevant prometheus-related configuration in an ExtendedConfig object | ||
func (ec *ExtendedConfig) Init() { | ||
ec.MetricsRegistry = prometheus.NewRegistry() | ||
ec.GaugeMetric = prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Name: "trivy", | ||
Help: "Gauge Metrics associated with trivy - Last DB Update, Last DB Update Attempt ...", | ||
}, | ||
[]string{"action"}, | ||
) | ||
ec.MetricsRegistry.MustRegister(ec.GaugeMetric) | ||
} |
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