commit
ea6d57531e
3 changed files with 5 additions and 5 deletions
|
@ -125,7 +125,7 @@ func (p nginxStatusCollector) Stop() {
|
||||||
close(p.scrapeChan)
|
close(p.scrapeChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
// nginxStatusCollector scrap the nginx status
|
// nginxStatusCollector scrape the nginx status
|
||||||
func (p nginxStatusCollector) scrape(ch chan<- prometheus.Metric) {
|
func (p nginxStatusCollector) scrape(ch chan<- prometheus.Metric) {
|
||||||
s, err := getNginxStatus(p.ngxHealthPort, p.ngxVtsPath)
|
s, err := getNginxStatus(p.ngxHealthPort, p.ngxVtsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -145,7 +145,7 @@ func (bit BoolToFloat64) UnmarshalJSON(data []byte) error {
|
||||||
|
|
||||||
func getNginxStatus(port int, path string) (*basicStatus, error) {
|
func getNginxStatus(port int, path string) (*basicStatus, error) {
|
||||||
url := fmt.Sprintf("http://localhost:%v%v", port, path)
|
url := fmt.Sprintf("http://localhost:%v%v", port, path)
|
||||||
glog.V(3).Infof("start scrapping url: %v", url)
|
glog.V(3).Infof("start scraping url: %v", url)
|
||||||
|
|
||||||
data, err := httpBody(url)
|
data, err := httpBody(url)
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ func httpBody(url string) ([]byte, error) {
|
||||||
|
|
||||||
func getNginxVtsMetrics(port int, path string) (*vts, error) {
|
func getNginxVtsMetrics(port int, path string) (*vts, error) {
|
||||||
url := fmt.Sprintf("http://localhost:%v%v", port, path)
|
url := fmt.Sprintf("http://localhost:%v%v", port, path)
|
||||||
glog.V(3).Infof("start scrapping url: %v", url)
|
glog.V(3).Infof("start scraping url: %v", url)
|
||||||
|
|
||||||
data, err := httpBody(url)
|
data, err := httpBody(url)
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ func getNginxVtsMetrics(port int, path string) (*vts, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unexpected error json unmarshal (%v)", err)
|
return nil, fmt.Errorf("unexpected error json unmarshal (%v)", err)
|
||||||
}
|
}
|
||||||
glog.V(3).Infof("scrap returned : %v", vts)
|
glog.V(3).Infof("scrape returned : %v", vts)
|
||||||
return vts, nil
|
return vts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
This example aims to demonstrate the deployment of an nginx ingress controller and
|
This example aims to demonstrate the deployment of an nginx ingress controller and
|
||||||
use a ConfigMap to enable nginx vts module and export metrics for prometheus,to enable
|
use a ConfigMap to enable nginx vts module and export metrics for prometheus,to enable
|
||||||
vts metric,you can simply run `kubectl apply -f nginx`,a deployment and service will be
|
vts metric,you can simply run `kubectl apply -f nginx`,a deployment and service will be
|
||||||
created which already has a `prometheus.io/scrap: 'true'` annotation and if you added
|
created which already has a `prometheus.io/scrape: 'true'` annotation and if you added
|
||||||
the recommended Prometheus service-endpoint scraping [configuration](https://raw.githubusercontent.com/prometheus/prometheus/master/documentation/examples/prometheus-kubernetes.yml),
|
the recommended Prometheus service-endpoint scraping [configuration](https://raw.githubusercontent.com/prometheus/prometheus/master/documentation/examples/prometheus-kubernetes.yml),
|
||||||
Prometheus will scrape it automatically and you start using the generated metrics right away.
|
Prometheus will scrape it automatically and you start using the generated metrics right away.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue