Skip to content

Commit

Permalink
Merge pull request #81 from flashcatcloud/modify_default_settings
Browse files Browse the repository at this point in the history
modify default settings
  • Loading branch information
UlricQin authored Jul 11, 2022
2 parents 43fbccb + e9d7d50 commit 2cc6da2
Show file tree
Hide file tree
Showing 31 changed files with 161 additions and 81 deletions.
6 changes: 3 additions & 3 deletions conf/input.exec/exec.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# # collect interval
# interval = 15

# [[instances]]
[[instances]]
# # commands, support glob
# commands = [
commands = [
# "/opt/categraf/scripts/*.sh"
# ]
]

# # timeout for each command to complete
# timeout = 5
Expand Down
6 changes: 3 additions & 3 deletions conf/input.http_response/http_response.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# # collect interval
# interval = 15

# [[instances]]
# targets = [
[[instances]]
targets = [
# "http://localhost",
# "https://www.baidu.com"
# ]
]

# # append some labels for series
# labels = { region="cloud", product="n9e" }
Expand Down
3 changes: 2 additions & 1 deletion conf/input.kafka/kafka.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ labels = { cluster="kafka-cluster-01" }
log_level = "error"

# Address (host:port) of Kafka server.
kafka_uris = ["127.0.0.1:9092","127.0.0.1:9092","127.0.0.1:9092"]
# kafka_uris = ["127.0.0.1:9092","127.0.0.1:9092","127.0.0.1:9092"]
kafka_uris = []

# Connect using SASL/PLAIN
# Default is false
Expand Down
5 changes: 3 additions & 2 deletions conf/input.kubernetes/kubernetes.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# # collect interval
# interval = 15

# [[instances]]
[[instances]]
# # append some labels for series
# labels = { region="cloud", product="n9e" }

# # interval = global.interval * interval_times
# interval_times = 1

# URL for the kubelet
url = "https://$HOSTIP:10250"
# url = "https://$HOSTIP:10250"
url = ""

gather_system_container_metrics = true
gather_node_metrics = true
Expand Down
2 changes: 1 addition & 1 deletion conf/input.mysql/mysql.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# # collect interval
# interval = 15

# [[instances]]
[[instances]]
# address = "127.0.0.1:3306"
# username = "root"
# password = "1234"
Expand Down
6 changes: 3 additions & 3 deletions conf/input.net_response/net_response.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# # collect interval
# interval = 15

# [[instances]]
# targets = [
[[instances]]
targets = [
# "127.0.0.1:22",
# "localhost:6379",
# ":9090"
# ]
]

# # append some labels for series
# labels = { region="cloud", product="n9e" }
Expand Down
3 changes: 2 additions & 1 deletion conf/input.nvidia_smi/nvidia_smi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# interval = 15

# exec local command
# nvidia_smi_command = "nvidia-smi"
# e.g. nvidia_smi_command = "nvidia-smi"
nvidia_smi_command = ""

# exec remote command
# nvidia_smi_command = "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null SSH_USER@SSH_HOST nvidia-smi"
Expand Down
2 changes: 1 addition & 1 deletion conf/input.oracle/oracle.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# # collect interval
# interval = 15

# [[instances]]
[[instances]]
# address = "10.1.2.3:1521/orcl"
# username = "monitor"
# password = "123456"
Expand Down
6 changes: 3 additions & 3 deletions conf/input.ping/ping.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# # collect interval
# interval = 15

# [[instances]]
[[instances]]
# send ping packets to
# targets = [
targets = [
# "www.baidu.com",
# "127.0.0.1",
# "10.4.5.6",
# "10.4.5.7"
# ]
]

# # append some labels for series
# labels = { region="cloud", product="n9e" }
Expand Down
26 changes: 13 additions & 13 deletions conf/input.prometheus/prometheus.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
# interval = 15

[[instances]]
# urls = [
urls = [
# "http://localhost:9104/metrics"
# ]
]

url_label_key = "instance"
url_label_value = "{{.Host}}"

## Scrape Services available in Consul Catalog
[instances.consul]
enabled = false
agent = "http://localhost:8500"
query_interval = "5m"

[[instances.consul.query]]
name = "a service name"
tag = "a service tag"
url = 'http://{{if ne .ServiceAddress ""}}{{.ServiceAddress}}{{else}}{{.Address}}{{end}}:{{.ServicePort}}/{{with .ServiceMeta.metrics_path}}{{.}}{{else}}metrics{{end}}'
[instances.consul.query.tags]
host = "{{.Node}}"
# [instances.consul]
# enabled = false
# agent = "http://localhost:8500"
# query_interval = "5m"

# [[instances.consul.query]]
# name = "a service name"
# tag = "a service tag"
# url = 'http://{{if ne .ServiceAddress ""}}{{.ServiceAddress}}{{else}}{{.Address}}{{end}}:{{.ServicePort}}/{{with .ServiceMeta.metrics_path}}{{.}}{{else}}metrics{{end}}'
# [instances.consul.query.tags]
# host = "{{.Node}}"

# bearer_token_string = ""

Expand Down
2 changes: 1 addition & 1 deletion conf/input.rabbitmq/rabbitmq.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# # collect interval
# interval = 15

# [[instances]]
[[instances]]
# # Management Plugin url
# url = "http://localhost:15672"
# username = "guest"
Expand Down
2 changes: 1 addition & 1 deletion conf/input.redis/redis.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# # collect interval
# interval = 15

# [[instances]]
[[instances]]
# address = "127.0.0.1:6379"
# username = ""
# password = ""
Expand Down
6 changes: 3 additions & 3 deletions conf/input.switch_legacy/switch_legacy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ switch_id_label = "ip"
"192.168.88.160" = "switch001.bj"
"192.168.88.161" = "switch002.bj"

# [[instances]]
[[instances]]
# # interval = global.interval * interval_times
# interval_times = 1

# use global unique string to specify instance
# labels = { region="beijing" }

# ips = [
ips = [
# "172.16.2.1",
# "172.16.4/24",
# "192.168.56.102-192.168.56.120"
# ]
]

community = "public"

Expand Down
3 changes: 2 additions & 1 deletion conf/input.tomcat/tomcat.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# interval = 15

# Gather metrics from the Tomcat server status page.
# [[instances]]
[[instances]]
## URL of the Tomcat server status
# url = "http://127.0.0.1:8080/manager/status/all?XML=true"
url = ""

## HTTP Basic Auth Credentials
# username = "tomcat"
Expand Down
2 changes: 1 addition & 1 deletion conf/input.zookeeper/zookeeper.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# # collect interval
# interval = 15

# [[instances]]
[[instances]]
# cluster_name = "dev-zk-cluster"
# addresses = "127.0.0.1:2181"
# timeout = 10
Expand Down
6 changes: 6 additions & 0 deletions inputs/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func (e *Exec) Init() error {
}

for i := 0; i < len(e.Instances); i++ {
if len(e.Instances[i].Commands) == 0 {
continue
}
if e.Instances[i].DataFormat == "" || e.Instances[i].DataFormat == "influx" {
e.Instances[i].parser = influx.NewParser()
} else if e.Instances[i].DataFormat == "falcon" {
Expand All @@ -82,6 +85,9 @@ func (e *Exec) Gather(slist *list.SafeList) {
wg.Add(len(e.Instances))
for i := range e.Instances {
ins := e.Instances[i]
if len(ins.Commands) == 0 {
continue
}
go e.GatherOnce(&wg, slist, ins)
}

Expand Down
12 changes: 7 additions & 5 deletions inputs/http_response/http_response.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package http_response

import (
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -59,6 +58,10 @@ type httpClient interface {
}

func (ins *Instance) Init() error {
if len(ins.Targets) == 0 {
return nil
}

if ins.ResponseTimeout < config.Duration(time.Second) {
ins.ResponseTimeout = config.Duration(time.Second * 3)
}
Expand All @@ -67,10 +70,6 @@ func (ins *Instance) Init() error {
ins.Method = "GET"
}

if len(ins.Targets) == 0 {
return errors.New("http_response targets empty")
}

client, err := ins.createHTTPClient()
if err != nil {
return fmt.Errorf("failed to create http client: %v", err)
Expand Down Expand Up @@ -174,6 +173,9 @@ func (h *HTTPResponse) Gather(slist *list.SafeList) {
atomic.AddUint64(&h.Counter, 1)
for i := range h.Instances {
ins := h.Instances[i]
if len(ins.Targets) == 0 {
continue
}
h.wg.Add(1)
go h.gatherOnce(slist, ins)
}
Expand Down
7 changes: 6 additions & 1 deletion inputs/kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func (r *Kafka) Gather(slist *list.SafeList) {
for i := range r.Instances {
ins := r.Instances[i]

if len(ins.KafkaURIs) == 0 {
continue
}

r.waitgrp.Add(1)
go func(slist *list.SafeList, ins *Instance) {
defer r.waitgrp.Done()
Expand Down Expand Up @@ -159,8 +163,9 @@ type Instance struct {

func (ins *Instance) Init() error {
if len(ins.KafkaURIs) == 0 || ins.KafkaURIs[0] == "" {
return fmt.Errorf("kafka_uris must be specified")
return nil
}

if ins.UseTLS && (ins.CertFile == "" || ins.KeyFile == "") {
return fmt.Errorf("tls is enabled but key pair was not provided")
}
Expand Down
29 changes: 16 additions & 13 deletions inputs/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package kubernetes

import (
"encoding/json"
"errors"
"fmt"
"log"
"net/http"
Expand Down Expand Up @@ -64,6 +63,10 @@ func (k *Kubernetes) Gather(slist *list.SafeList) {
for i := range k.Instances {
ins := k.Instances[i]

if ins.URL == "" {
continue
}

k.waitgrp.Add(1)
go func(slist *list.SafeList, ins *Instance) {
defer k.waitgrp.Done()
Expand Down Expand Up @@ -113,7 +116,7 @@ type Instance struct {

func (ins *Instance) Init() error {
if ins.URL == "" {
return errors.New("url is blank")
return nil
}

ins.URL = os.Expand(ins.URL, config.GetEnv)
Expand Down Expand Up @@ -185,10 +188,10 @@ func (ins *Instance) buildPodMetrics(summaryMetrics *SummaryMetrics, podInfo []M
if ins.GatherPodContainerMetrics {
for _, container := range pod.Containers {
tags := map[string]string{
"node": summaryMetrics.Node.NodeName,
"namespace": pod.PodRef.Namespace,
"container": container.Name,
"pod": pod.PodRef.Name,
"node": summaryMetrics.Node.NodeName,
"namespace": pod.PodRef.Namespace,
"container": container.Name,
"pod": pod.PodRef.Name,
}
for k, v := range podLabels {
tags[k] = v
Expand All @@ -214,10 +217,10 @@ func (ins *Instance) buildPodMetrics(summaryMetrics *SummaryMetrics, podInfo []M
if ins.GatherPodVolumeMetrics {
for _, volume := range pod.Volumes {
tags := map[string]string{
"node": summaryMetrics.Node.NodeName,
"pod": pod.PodRef.Name,
"namespace": pod.PodRef.Namespace,
"volume": volume.Name,
"node": summaryMetrics.Node.NodeName,
"pod": pod.PodRef.Name,
"namespace": pod.PodRef.Namespace,
"volume": volume.Name,
}
for k, v := range podLabels {
tags[k] = v
Expand Down Expand Up @@ -252,8 +255,8 @@ func (ins *Instance) buildPodMetrics(summaryMetrics *SummaryMetrics, podInfo []M
func (ins *Instance) buildSystemContainerMetrics(summaryMetrics *SummaryMetrics, slist *list.SafeList) {
for _, container := range summaryMetrics.Node.SystemContainers {
tags := map[string]string{
"node": summaryMetrics.Node.NodeName,
"container": container.Name,
"node": summaryMetrics.Node.NodeName,
"container": container.Name,
}

fields := make(map[string]interface{})
Expand All @@ -275,7 +278,7 @@ func (ins *Instance) buildSystemContainerMetrics(summaryMetrics *SummaryMetrics,

func (ins *Instance) buildNodeMetrics(summaryMetrics *SummaryMetrics, slist *list.SafeList) {
tags := map[string]string{
"node": summaryMetrics.Node.NodeName,
"node": summaryMetrics.Node.NodeName,
}
fields := make(map[string]interface{})
fields["node_cpu_usage_nanocores"] = summaryMetrics.Node.CPU.UsageNanoCores
Expand Down
Loading

0 comments on commit 2cc6da2

Please sign in to comment.