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

[summerospp]add fluentbit nginx plugin #924

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apis/fluentbit/v1alpha2/clusterinput_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type InputSpec struct {
Collectd *input.Collectd `json:"collectd,omitempty"`
// StatsD defines the StatsD input plugin configuration
StatsD *input.StatsD `json:"statsd,omitempty"`
// Nginx defines the Nginx input plugin configuration
Nginx *input.Nginx `json:"nginx,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
47 changes: 47 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/input/nginx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package input

import (
"fmt"

"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins"
"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins/params"
)

// +kubebuilder:object:generate:=true

// NGINX Exporter Metrics input plugin scrapes metrics from the NGINX stub status handler. <br />
// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/nginx**
type Nginx struct {
// Name of the target host or IP address to check, default: localhost
Host string `json:"host,omitempty"`
// Port of the target nginx service to connect to, default: 80
// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=65535
Port *int32 `json:"port,omitempty"`
// The URL of the Stub Status Handler,default: /status
StatusURL string `json:"statusURL,omitempty"`
// Turn on NGINX plus mode,default: true
NginxPlus *bool `json:"nginxPlus,omitempty"`
}

func (_ *Nginx) Name() string {
return "nginx_metrics"
}

// implement Section() method
func (n *Nginx) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if n.Host != "" {
kvs.Insert("Host", n.Host)
}
if n.Port != nil {
kvs.Insert("Port", fmt.Sprint(*n.Port))
}
if n.StatusURL != "" {
kvs.Insert("Status_URL", n.StatusURL)
}
if n.NginxPlus != nil {
kvs.Insert("Nginx_Plus", fmt.Sprint(*n.NginxPlus))
}
return kvs, nil
}
25 changes: 25 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions apis/fluentbit/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,27 @@ spec:
minimum: 1
type: integer
type: object
nginx:
description: Nginx defines the Nginx input plugin configuration
properties:
host:
description: 'Name of the target host or IP address to check,
default: localhost'
type: string
nginxPlus:
description: 'Turn on NGINX plus mode,default: true'
type: boolean
port:
description: 'Port of the target nginx service to connect to,
default: 80'
format: int32
maximum: 65535
minimum: 1
type: integer
statusURL:
description: 'The URL of the Stub Status Handler,default: /status'
type: string
type: object
nodeExporterMetrics:
description: NodeExporterMetrics defines Node Exporter Metrics Input
configuration.
Expand Down
21 changes: 21 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,27 @@ spec:
minimum: 1
type: integer
type: object
nginx:
description: Nginx defines the Nginx input plugin configuration
properties:
host:
description: 'Name of the target host or IP address to check,
default: localhost'
type: string
nginxPlus:
description: 'Turn on NGINX plus mode,default: true'
type: boolean
port:
description: 'Port of the target nginx service to connect to,
default: 80'
format: int32
maximum: 65535
minimum: 1
type: integer
statusURL:
description: 'The URL of the Stub Status Handler,default: /status'
type: string
type: object
nodeExporterMetrics:
description: NodeExporterMetrics defines Node Exporter Metrics Input
configuration.
Expand Down
3 changes: 2 additions & 1 deletion docs/fluentbit.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ FluentBitSpec defines the desired state of FluentBit
| priorityClassName | PriorityClassName represents the pod's priority class. | string |
| volumes | List of volumes that can be mounted by containers belonging to the pod. | []corev1.Volume |
| volumesMounts | Pod volumes to mount into the container's filesystem. | []corev1.VolumeMount |
| disableLogVolumes | DisableLogVolumes removes the hostPath mounts for varlibcontainers, varlogs and systemd. | bool |
| annotations | Annotations to add to each Fluentbit pod. | map[string]string |
| serviceAccountAnnotations | Annotations to add to the Fluentbit service account | map[string]string |
| labels | Labels to add to each FluentBit pod | map[string]string |
Expand All @@ -400,7 +401,6 @@ FluentBitSpec defines the desired state of FluentBit
| metricsPort | MetricsPort is the port used by the metrics server. If this option is set, HttpPort from ClusterFluentBitConfig needs to match this value. Default is 2020. | int32 |
| service | Service represents configurations on the fluent-bit service. | FluentBitService |
| schedulerName | SchedulerName represents the desired scheduler for fluent-bit pods. | string |
| disableLogVolumes | DisableLogVolumes removes the hostPath mounts for varlibcontainers, varlogs and systemd. | bool |

[Back to TOC](#table-of-contents)
# InputSpec
Expand All @@ -425,6 +425,7 @@ InputSpec defines the desired state of ClusterInput
| mqtt | MQTT defines the MQTT input plugin configuration | *[input.MQTT](plugins/input/mqtt.md) |
| collectd | Collectd defines the Collectd input plugin configuration | *[input.Collectd](plugins/input/collectd.md) |
| statsd | StatsD defines the StatsD input plugin configuration | *[input.StatsD](plugins/input/statsd.md) |
| nginx | Nginx defines the Nginx input plugin configuration | *[input.Nginx](plugins/input/nginx.md) |

[Back to TOC](#table-of-contents)
# NamespacedFluentBitCfgSpec
Expand Down
11 changes: 11 additions & 0 deletions docs/plugins/fluentbit/input/nginx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Nginx

NGINX Exporter Metrics input plugin scrapes metrics from the NGINX stub status handler. <br /> **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/nginx**


| Field | Description | Scheme |
| ----- | ----------- | ------ |
| host | Name of the target host or IP address to check, default: localhost | string |
| port | Port of the target nginx service to connect to, default: 80 | *int32 |
| statusURL | The URL of the Stub Status Handler,default: /status | string |
| nginxPlus | Turn on NGINX plus mode,default: true | *bool |
21 changes: 21 additions & 0 deletions manifests/setup/fluent-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,27 @@ spec:
minimum: 1
type: integer
type: object
nginx:
description: Nginx defines the Nginx input plugin configuration
properties:
host:
description: 'Name of the target host or IP address to check,
default: localhost'
type: string
nginxPlus:
description: 'Turn on NGINX plus mode,default: true'
type: boolean
port:
description: 'Port of the target nginx service to connect to,
default: 80'
format: int32
maximum: 65535
minimum: 1
type: integer
statusURL:
description: 'The URL of the Stub Status Handler,default: /status'
type: string
type: object
nodeExporterMetrics:
description: NodeExporterMetrics defines Node Exporter Metrics Input
configuration.
Expand Down
21 changes: 21 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,27 @@ spec:
minimum: 1
type: integer
type: object
nginx:
description: Nginx defines the Nginx input plugin configuration
properties:
host:
description: 'Name of the target host or IP address to check,
default: localhost'
type: string
nginxPlus:
description: 'Turn on NGINX plus mode,default: true'
type: boolean
port:
description: 'Port of the target nginx service to connect to,
default: 80'
format: int32
maximum: 65535
minimum: 1
type: integer
statusURL:
description: 'The URL of the Stub Status Handler,default: /status'
type: string
type: object
nodeExporterMetrics:
description: NodeExporterMetrics defines Node Exporter Metrics Input
configuration.
Expand Down
Loading