Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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 ?

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.

None yet

2 participants