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

feat(plugin): support Prometheus Scrape Metrics (#355) and Prometheus… #362

Merged
merged 3 commits into from
Aug 24, 2022
Merged

Conversation

tonyzaizai
Copy link
Collaborator

… Remote Write plugins(#348)

Signed-off-by: tl 361944459@qq.com

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #348 and #355

Does this PR introduced a user-facing change?


Additional documentation, usage docs, etc.:


… Remote Write plugins(#348)

Signed-off-by: tl <361944459@qq.com>
HTTPUser *plugins.Secret `json:"httpUser,omitempty"`
// Basic Auth Password.
// Requires HTTP_user to be se
HTTPPasswd *plugins.Secret `json:"httpPassword,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
HTTPPasswd *plugins.Secret `json:"httpPassword,omitempty"`
HTTPPasswd *plugins.Secret `json:"httpPasswd,omitempty"`

should be consistent with http_passwd https://docs.fluentbit.io/manual/pipeline/outputs/prometheus-remote-write

//Log the response payload within the Fluent Bit log,default: false
LogResponsePayload *bool `json:"logResponsePayload,omitempty"`
//This allows you to add custom labels to all metrics exposed through the prometheus exporter. You may have multiple of these fields
AddLabels []string `json:"addLabels,omitempty"`
Copy link
Member

@benjaminhuo benjaminhuo Aug 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AddLabels should be similar to Headers, allowing to add multiple kv pairs just like opentelemetry plugin did:
https://docs.fluentbit.io/manual/pipeline/outputs/prometheus-remote-write
image

https://docs.fluentbit.io/manual/pipeline/outputs/opentelemetry
image

// +kubebuilder:validation:Maximum:=65535
Port *int32 `json:"port,omitempty"`
// The interval to scrape metrics, default: 10s
ScrapeInterval *int32 `json:"scrapeInterval,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this should be a string or duration?

1661216273

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mimicked the node exporter Metrics plug-in, which defines Int32

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing to determine it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be a string and the support value format is 1, 1s, 1D, 1d, 1H, 1H, 1M, 1m

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Maybe you're right. Here's the example

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mimicked the node exporter Metrics plug-in, which defines Int32

@tonyzaizai Would you help to update the node exporter input plugin as well?
https://github.com/fluent/fluent-operator/blob/master/apis/fluentbit/v1alpha2/plugins/input/node_exporter_metrics_types.go#L18

According to the discussion we've had with the fluent community, it should be like 10s, 1m https://fluent-all.slack.com/archives/C02642TE9HR/p1658215209357549

image

And we need some test for this plugin too. Maybe you can run a fluentibt binary to collect node metrics and see if config like 15s works

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
I tested it with the fluent-bit binary and it works for 1 or 1s or 1M
image
The Node Expoter input plugin should be the same

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image

The interval is indeed one minute

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good. It's in format 10s, 1m...

// Specify an HTTP Proxy. The expected format of this value is http://HOST:PORT.
Proxy string `json:"proxy,omitempty"`
//Specify an optional HTTP URI for the target web server, e.g: /something ,default: /
Uri string `json:"uri,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uri string `json:"uri,omitempty"`

=>

URI string `json:"uri,omitempty"`

// +kubebuilder:object:generate:=true

// An output plugin to submit Prometheus Metrics using the remote write protocol
type PrometheusRemoteWrite struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it not support workers?

1661216556(1)

…_write plugins

Signed-off-by: tl <361944459@qq.com>
…_metrics plugins

Signed-off-by: tl <361944459@qq.com>
}

func (_ *PrometheusScrapeMetrics) Name() string {
return "prometheus_scrape"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prometheus_scrape_metrics is ok instead of prometheus_scrape

@@ -26,6 +27,14 @@ var inputExpected = `[Input]
Tag logs.foo.bar
Rate 3
Samples 5
[Input]
Name prometheus_scrape
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prometheus_scrape_metrics is ok instead of prometheus_scrape

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

image

It seems that it must be the "prometheus_scrape" field

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the content of the configuration file you used?
Does the name of the plugin in the configuration file is set to prometheus_scape?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image

"prometheus_scrape_metrics" is not effective

image
image

"prometheus_scrape" is ok

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let's keep it this way

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.

Add the PrometheusRemoteWrite output plugin
3 participants