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

Couchdb Metrics Receiver #340

Merged
merged 14 commits into from
Feb 4, 2022
63 changes: 63 additions & 0 deletions apps/couchdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apps

import (
"github.com/GoogleCloudPlatform/ops-agent/confgenerator"
"github.com/GoogleCloudPlatform/ops-agent/confgenerator/otel"
)

type MetricsReceiverCouchdb struct {
confgenerator.ConfigComponent `yaml:",inline"`

confgenerator.MetricsReceiverShared `yaml:",inline"`

Endpoint string `yaml:"endpoint" validate:"omitempty,url,startswith=http:"`
Username string `yaml:"username" validate:"required_with=Password"`
Password string `yaml:"password" validate:"required_with=Username"`
}

const defaultCouchdbEndpoint = "http://localhost:5984"

func (MetricsReceiverCouchdb) Type() string {
return "couchdb"
}

func (r MetricsReceiverCouchdb) Pipelines() []otel.Pipeline {
if r.Endpoint == "" {
r.Endpoint = defaultCouchdbEndpoint
}
return []otel.Pipeline{{
Receiver: otel.Component{
Type: "couchdb",
Config: map[string]interface{}{
"collection_interval": r.CollectionIntervalString(),
"endpoint": r.Endpoint,
"username": r.Username,
"password": r.Password,
},
},
Processors: []otel.Component{
otel.NormalizeSums(),
otel.MetricsTransform(
otel.AddPrefix("workload.googleapis.com"),
),
},
}}
}

func init() {
confgenerator.MetricsReceiverTypes.RegisterType(func() confgenerator.Component { return &MetricsReceiverCouchdb{} })
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[19:17] "endpoint" must start with "http:"
16 | receivers:
17 | couchdb:
18 | type: couchdb
> 19 | endpoint: localhost:5984
^
20 | service:
21 | pipelines:
22 | couchdb:
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

metrics:
receivers:
couchdb:
type: couchdb
endpoint: localhost:5984
service:
pipelines:
couchdb:
receivers:
- couchdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[19:17] "endpoint" must be a URL
16 | receivers:
17 | couchdb:
18 | type: couchdb
> 19 | endpoint: localhost
^
20 | service:
21 | pipelines:
22 | couchdb:
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

metrics:
receivers:
couchdb:
type: couchdb
endpoint: localhost
service:
pipelines:
couchdb:
receivers:
- couchdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[17:12] "username" is required when "Password" is set
15 | metrics:
16 | receivers:
> 17 | couchdb:
^
18 | type: couchdb
19 | endpoint: http://localhost:5984
20 | password: pass
21 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

metrics:
receivers:
couchdb:
type: couchdb
endpoint: http://localhost:5984
password: pass
service:
pipelines:
couchdb:
receivers:
- couchdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[17:12] "password" is required when "Username" is set
15 | metrics:
16 | receivers:
> 17 | couchdb:
^
18 | type: couchdb
19 | endpoint: http://localhost:5984
20 | username: usr
21 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

metrics:
receivers:
couchdb:
type: couchdb
endpoint: http://localhost:5984
username: usr
service:
pipelines:
couchdb:
receivers:
- couchdb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
metrics receiver with type "iis" is not supported. Supported metrics receiver types: [apache, cassandra, hostmetrics, jvm, memcached, mysql, nginx, postgresql, redis, solr, tomcat].
metrics receiver with type "iis" is not supported. Supported metrics receiver types: [apache, cassandra, couchdb, hostmetrics, jvm, memcached, mysql, nginx, postgresql, redis, solr, tomcat].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
metrics receiver with type "mssql" is not supported. Supported metrics receiver types: [apache, cassandra, hostmetrics, jvm, memcached, mysql, nginx, postgresql, redis, solr, tomcat].
metrics receiver with type "mssql" is not supported. Supported metrics receiver types: [apache, cassandra, couchdb, hostmetrics, jvm, memcached, mysql, nginx, postgresql, redis, solr, tomcat].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
metrics receiver with type "unsupported_type" is not supported. Supported metrics receiver types: [apache, cassandra, hostmetrics, jvm, memcached, mysql, nginx, postgresql, redis, solr, tomcat].
metrics receiver with type "unsupported_type" is not supported. Supported metrics receiver types: [apache, cassandra, couchdb, hostmetrics, jvm, memcached, mysql, nginx, postgresql, redis, solr, tomcat].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
metrics receiver with type "unsupported_type" is not supported. Supported metrics receiver types: [apache, cassandra, hostmetrics, iis, jvm, memcached, mssql, mysql, nginx, postgresql, redis, solr, tomcat].
metrics receiver with type "unsupported_type" is not supported. Supported metrics receiver types: [apache, cassandra, couchdb, hostmetrics, iis, jvm, memcached, mssql, mysql, nginx, postgresql, redis, solr, tomcat].
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
@SET buffers_dir=/var/lib/google-cloud-ops-agent/fluent-bit/buffers
@SET logs_dir=/var/log/google-cloud-ops-agent/subagents

[SERVICE]
Daemon off
Flush 1
Log_Level info
dns.resolver legacy
storage.backlog.mem_limit 50M
storage.checksum on
storage.max_chunks_up 128
storage.metrics on
storage.sync normal

[INPUT]
Name fluentbit_metrics
Scrape_Interval 60
Scrape_On_Start True

[INPUT]
Buffer_Chunk_Size 512k
Buffer_Max_Size 5M
DB ${buffers_dir}/default_pipeline_syslog
Key message
Mem_Buf_Limit 10M
Name tail
Path /var/log/messages,/var/log/syslog
Read_from_Head True
Rotate_Wait 30
Skip_Long_Lines On
Tag default_pipeline.syslog
storage.type filesystem

[INPUT]
Buffer_Chunk_Size 512k
Buffer_Max_Size 5M
DB ${buffers_dir}/ops-agent-fluent-bit
Key message
Mem_Buf_Limit 10M
Name tail
Path ${logs_dir}/logging-module.log
Read_from_Head True
Rotate_Wait 30
Skip_Long_Lines On
Tag ops-agent-fluent-bit
storage.type filesystem

[FILTER]
Add logging.googleapis.com/logName syslog
Match default_pipeline.syslog
Name modify

[OUTPUT]
Match_Regex ^(default_pipeline\.syslog)$
Name stackdriver
Retry_Limit 3
net.connect_timeout_log_error False
resource gce_instance
stackdriver_agent Google-Cloud-Ops-Agent-Logging/latest (BuildDistro=build_distro;Platform=linux;ShortName=linux_platform;ShortVersion=linux_platform_version)
tls On
tls.verify Off
workers 8

[OUTPUT]
Match_Regex ^(ops-agent-fluent-bit)$
Name stackdriver
Retry_Limit 3
net.connect_timeout_log_error False
resource gce_instance
stackdriver_agent Google-Cloud-Ops-Agent-Logging/latest (BuildDistro=build_distro;Platform=linux;ShortName=linux_platform;ShortVersion=linux_platform_version)
tls On
tls.verify Off
workers 8

[OUTPUT]
Match *
Name prometheus_exporter
host 0.0.0.0
port 20202
Loading