-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Basic logic for the metrics exporter. * Basic docker compose file to start a prometheus and grafana instance for testing. * Metrics collection under provider. * Documentation Fixes #210
- Loading branch information
Showing
17 changed files
with
468 additions
and
7 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
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,17 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/sirupsen/logrus" | ||
|
||
"github.com/weaveworks/flintlock/internal/command/metrics" | ||
) | ||
|
||
func main() { | ||
app := metrics.NewApp(os.Stdout) | ||
|
||
if err := app.Run(os.Args); err != nil { | ||
logrus.Error(err) | ||
} | ||
} |
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
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
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,12 @@ | ||
version: "3.9" | ||
services: | ||
prom: | ||
image: prom/prometheus | ||
ports: | ||
- 9090 | ||
volumes: | ||
- ./prometheus.yml:/etc/prometheus/prometheus.yml | ||
grafana: | ||
image: grafana/grafana:8.3.3 | ||
ports: | ||
- 3000:3000 |
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,14 @@ | ||
global: | ||
scrape_interval: 15s | ||
evaluation_interval: 30s | ||
|
||
scrape_configs: | ||
- job_name: 'prometheus' | ||
static_configs: | ||
- targets: ['127.0.0.1:9090'] | ||
|
||
- job_name: flintlock | ||
scrape_interval: 5s | ||
metrics_path: '/machine' | ||
static_configs: | ||
- targets: ['192.168.100.35:8090'] |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package firecracker | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type MachineMetrics struct { | ||
Namespace string `json:"Namespace"` | ||
MachineName string `json:"MachineName"` | ||
MachineUID string `json:"MachineUID"` | ||
Data Metrics `json:"Data"` | ||
} | ||
|
||
type Metrics map[string]map[string]int64 | ||
|
||
func (mm MachineMetrics) ToPrometheus() []byte { | ||
output := []string{} | ||
labels := strings.Join( | ||
[]string{ | ||
metricsLabel("namespace", mm.Namespace), | ||
metricsLabel("name", mm.MachineName), | ||
metricsLabel("uid", mm.MachineUID), | ||
}, | ||
",", | ||
) | ||
|
||
for prefix, group := range mm.Data { | ||
for key, value := range group { | ||
output = append(output, fmt.Sprintf("%s_%s{%s} %d", prefix, key, labels, value)) | ||
} | ||
} | ||
|
||
return []byte(strings.Join(output, "\n")) | ||
} | ||
|
||
func metricsLabel(key, value string) string { | ||
return fmt.Sprintf("%s=\"%s\"", key, value) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.