-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Metrics Feature #775
base: master
Are you sure you want to change the base?
API Metrics Feature #775
Conversation
I have the feeling this PR will not be accepted as it is, because you are already proposing other changes unrelated to the prometheus metrics. Th fastest way to have this feature merged is probably go easy on @crazy-max and provide him with a clean MR easy to review. |
apimetrics: | ||
enableApi: true | ||
enableScan: true | ||
token: ApiToken | ||
port: 6080 | ||
apiPath: /v1/metrics | ||
scanPath: /v1/scan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keys have inconsistent casing. It should probably be snake case ?
Notif *model.Notif `yaml:"notif,omitempty" json:"notif,omitempty"` | ||
RegOpts model.RegOpts `yaml:"regopts,omitempty" json:"regopts,omitempty" validate:"unique=Name,dive"` | ||
Providers *model.Providers `yaml:"providers,omitempty" json:"providers,omitempty"` | ||
APIMetrics *model.APIMetrics `yaml:"apimetrics,omitempty" json:"metricsapi,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The yaml and json key are different.
I personally think the naming is not the best, maybe "metrics" alone in better ?
// New is a factory function creating a new Handler instance | ||
func New(scanFn func()) *Handler { | ||
return &Handler{ | ||
fn: scanFn, | ||
Path: "/v1/scan", | ||
} | ||
} | ||
|
||
// Handler is an API handler used for triggering container update scans | ||
type Handler struct { | ||
fn func() | ||
Path string | ||
} | ||
|
||
// Handle is the actual http.Handle function doing all the heavy lifting | ||
func (handle *Handler) Handle(w http.ResponseWriter, r *http.Request) { | ||
log.Info().Msg("Updates triggered by HTTP API request.") | ||
|
||
_, err := io.Copy(os.Stdout, r.Body) | ||
if err != nil { | ||
log.Error().Err(err).Msg("Error") | ||
return | ||
} | ||
|
||
handle.fn() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this used for in the context of the prometheus metrics ?
Added feature api end points for pulling metrics and triggering a new scan.
Added feature to pull docker images