-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.采集每node上的
kube-proxy
kubelet-node
指标时支持并发数配置和静态分片
2.服务组件采集支持并发数设置 3.每种项目配置了相关配置段才会开启,如果不想采集某类指标可以去掉其配置
- Loading branch information
Showing
23 changed files
with
871 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,12 @@ | ||
package collect | ||
|
||
import ( | ||
"github.com/didi/nightingale/src/common/dataobj" | ||
"github.com/go-kit/kit/log" | ||
"github.com/go-kit/kit/log/level" | ||
"github.com/n9e/k8s-mon/config" | ||
"time" | ||
) | ||
|
||
func DoApiServerCollect(cg *config.Config, logger log.Logger, dataMap *HistoryMap, funcName string) { | ||
start := time.Now() | ||
// get dataM | ||
|
||
metricList := CurlMetricsByIps(cg.ApiServerC, logger, dataMap, funcName, cg.AppendTags, cg.Step, cg.TimeOutSeconds, cg.MultiServerInstanceUniqueLabel) | ||
|
||
if len(metricList) == 0 { | ||
level.Error(logger).Log("msg", "FinallyCurlTlsMetricsResEmpty", "func_name", funcName) | ||
return | ||
} | ||
|
||
// 设置nid | ||
ml := make([]dataobj.MetricValue, 0) | ||
for _, m := range metricList { | ||
m.Nid = cg.ServerSideNid | ||
ml = append(ml, m) | ||
|
||
} | ||
level.Info(logger).Log("msg", "DoCollectSuccessfullyReadyToPush", "funcName", funcName, "metrics_num", len(ml), "time_took_seconds", time.Since(start).Seconds()) | ||
go PushWork(cg.PushServerAddr, cg.TimeOutSeconds, ml, logger, funcName) | ||
ConcurrencyCurlMetricsByIpsSetNid(cg.ApiServerC, logger, dataMap, funcName, cg.AppendTags, cg.Step, cg.TimeOutSeconds, cg.MultiServerInstanceUniqueLabel, cg.MultiFuncUniqueLabel, cg.ServerSideNid, cg.PushServerAddr) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
package collect | ||
|
||
const ( | ||
FUNCNAME_APISERVER = "api-server" | ||
FUNCNAME_KUBESCHEDULER = "kube-scheduler" | ||
FUNCNAME_KUBECONTROLLER = "kube-controller-manager" | ||
FUNCNAME_COREDNS = "coredns" | ||
FUNCNAME_KUBELET = "kubelet" | ||
FUNCNAME_KUBESTATSMETRICS = "kube-stats-metrics" | ||
APPENDTAG_SERVER_ADDR = "server_addr" | ||
) | ||
const () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,12 @@ | ||
package collect | ||
|
||
import ( | ||
"github.com/didi/nightingale/src/common/dataobj" | ||
"github.com/go-kit/kit/log" | ||
"github.com/go-kit/kit/log/level" | ||
"github.com/n9e/k8s-mon/config" | ||
"time" | ||
) | ||
|
||
func DoKubeCoreDnsCollect(cg *config.Config, logger log.Logger, dataMap *HistoryMap, funcName string) { | ||
start := time.Now() | ||
metricList := CurlMetricsByIps(cg.CoreDnsC, logger, dataMap, funcName, cg.AppendTags, cg.Step, cg.TimeOutSeconds, cg.MultiServerInstanceUniqueLabel) | ||
|
||
if len(metricList) == 0 { | ||
level.Error(logger).Log("msg", "FinallyCurlTlsMetricsResEmpty", "func_name", funcName) | ||
return | ||
} | ||
ConcurrencyCurlMetricsByIpsSetNid(cg.CoreDnsC, logger, dataMap, funcName, cg.AppendTags, cg.Step, cg.TimeOutSeconds, cg.MultiServerInstanceUniqueLabel, cg.MultiFuncUniqueLabel, cg.ServerSideNid, cg.PushServerAddr) | ||
|
||
ml := make([]dataobj.MetricValue, 0) | ||
for _, m := range metricList { | ||
m.Nid = cg.ServerSideNid | ||
ml = append(ml, m) | ||
|
||
} | ||
level.Info(logger).Log("msg", "DoCollectSuccessfullyReadyToPush", "funcName", funcName, "metrics_num", len(ml), "time_took_seconds", time.Since(start).Seconds()) | ||
|
||
go PushWork(cg.PushServerAddr, cg.TimeOutSeconds, ml, logger, funcName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package collect | ||
|
||
import ( | ||
"context" | ||
"github.com/go-kit/kit/log" | ||
"github.com/go-kit/kit/log/level" | ||
kconfig "github.com/n9e/k8s-mon/config" | ||
apiv1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/rest" | ||
"time" | ||
) | ||
|
||
func GetServerAddrByGetNode(logger log.Logger, dataMap *HistoryMap) { | ||
start := time.Now() | ||
// creates the in-cluster config | ||
config, err := rest.InClusterConfig() | ||
if err != nil { | ||
level.Error(logger).Log("msg", "create_k8s_InClusterConfig_error", "err:", err) | ||
return | ||
} | ||
// creates the clientset | ||
clientset, err := kubernetes.NewForConfig(config) | ||
if err != nil { | ||
level.Error(logger).Log("msg", "creates_the_clientset_error", "err:", err) | ||
return | ||
} | ||
nodes, err := clientset.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{}) | ||
if err != nil { | ||
level.Error(logger).Log("msg", "list_kube-system_pod_error", "err:", err) | ||
return | ||
} | ||
|
||
nodeIps := make([]string, 0) | ||
if len(nodes.Items) == 0 { | ||
return | ||
} | ||
for _, p := range nodes.Items { | ||
addr := p.Status.Addresses | ||
if len(addr) == 0 { | ||
continue | ||
} | ||
for _, a := range addr { | ||
if a.Type == apiv1.NodeInternalIP { | ||
nodeIps = append(nodeIps, a.Address) | ||
} | ||
} | ||
} | ||
level.Info(logger).Log("msg", "server_node_ips_result", | ||
"num_nodeIps", len(nodeIps), | ||
"time_took_seconds", time.Since(start).Seconds(), | ||
) | ||
if len(nodeIps) > 0 { | ||
dataMap.Map.Store(kconfig.FUNCNAME_KUBELET_NODE, nodeIps) | ||
} | ||
|
||
} |
Oops, something went wrong.