Skip to content

API Metrics Feature#775

Open
AthrogatePEQ wants to merge 2 commits intocrazy-max:masterfrom
AthrogatePEQ:master
Open

API Metrics Feature#775
AthrogatePEQ wants to merge 2 commits intocrazy-max:masterfrom
AthrogatePEQ:master

Conversation

@AthrogatePEQ
Copy link

@AthrogatePEQ AthrogatePEQ commented Jan 26, 2023

Added feature api end points for pulling metrics and triggering a new scan.
Added feature to pull docker images

@jooola
Copy link

jooola commented Feb 15, 2023

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.

Comment on lines +6 to +12
apimetrics:
enableApi: true
enableScan: true
token: ApiToken
port: 6080
apiPath: /v1/metrics
scanPath: /v1/scan
Copy link

@jooola jooola Feb 15, 2023

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"`
Copy link

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 ?

Comment on lines +11 to +36
// 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()
}
Copy link

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 ?

@stablestud
Copy link

Hi @AthrogatePEQ would be awesome if you could get this merged, as this is really helpful. Would it be a problem if you took a look at @jooola suggestions and try to get it merged?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants