-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from go-faster/test/prombench
test(bench): add ch-bench compose
- Loading branch information
Showing
7 changed files
with
595 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
func (c *config) marshalYAML() []byte { | ||
data, err := yaml.Marshal(c) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return data | ||
} | ||
|
||
func newConfig(targetsCount int, scrapeInterval time.Duration, targetAddr string) *config { | ||
// https://github.com/VictoriaMetrics/prometheus-benchmark/blob/50c5891/services/vmagent-config-updater/main.go#L72-L94 | ||
scs := make([]*staticConfig, 0, targetsCount) | ||
for i := 0; i < targetsCount; i++ { | ||
scs = append(scs, &staticConfig{ | ||
Targets: []string{targetAddr}, | ||
Labels: map[string]string{ | ||
"instance": fmt.Sprintf("host-%d", i), | ||
"revision": "r0", | ||
}, | ||
}) | ||
} | ||
return &config{ | ||
Global: globalConfig{ | ||
ScrapeInterval: scrapeInterval, | ||
}, | ||
ScrapeConfigs: []*scrapeConfig{ | ||
{ | ||
JobName: "node_exporter", | ||
StaticConfigs: scs, | ||
Path: "/node", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
// config represents essential parts from Prometheus config defined at https://prometheus.io/docs/prometheus/latest/configuration/configuration/ | ||
type config struct { | ||
Global globalConfig `yaml:"global"` | ||
ScrapeConfigs []*scrapeConfig `yaml:"scrape_configs,omitempty"` | ||
RemoteWrites []*remoteWriteConfig `yaml:"remote_write,omitempty"` | ||
} | ||
|
||
// globalConfig represents essential parts for `global` section of Prometheus config. | ||
// | ||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/ | ||
type globalConfig struct { | ||
ScrapeInterval time.Duration `yaml:"scrape_interval"` | ||
} | ||
|
||
// rapeConfig represents essential parts for `scrape_config` section of Prometheus config. | ||
// | ||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config | ||
type scrapeConfig struct { | ||
JobName string `yaml:"job_name"` | ||
Path string `yaml:"metrics_path,omitempty"` | ||
StaticConfigs []*staticConfig `yaml:"static_configs"` | ||
} | ||
|
||
// staticConfig represents essential parts for `static_config` section of Prometheus config. | ||
// | ||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#static_config | ||
type staticConfig struct { | ||
Targets []string `yaml:"targets"` | ||
Labels map[string]string `yaml:"labels"` | ||
} | ||
|
||
// remoteWriteConfig represents essential parts for `remote_write` section of Prometheus config. | ||
// | ||
// https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write | ||
type remoteWriteConfig struct { | ||
URL string `yaml:"url"` | ||
Name string `yaml:"name,omitempty"` | ||
Metadata *remoteWriteMetadataConfig `yaml:"metadata_config,omitempty"` | ||
} | ||
|
||
type remoteWriteMetadataConfig struct { | ||
Send bool `yaml:"send"` | ||
SendInterval time.Duration `yaml:"send_interval,omitempty"` | ||
} |
Oops, something went wrong.