chore: pr cleanup on data generator
parent
32f2410597
commit
6d3ac4db46
|
@ -3,54 +3,54 @@ base_seed = "this is a demo"
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "role"
|
name = "role"
|
||||||
value = "storage"
|
template = "storage"
|
||||||
cardinality = 1
|
cardinality = 1
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "url"
|
name = "url"
|
||||||
value = "http://127.0.0.1:6060/metrics/usage"
|
template = "http://127.0.0.1:6060/metrics/usage"
|
||||||
cardinality = 1
|
cardinality = 1
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "org_id"
|
name = "org_id"
|
||||||
# Fill in the value with the cardinality counter and 15 random alphanumeric characters
|
# Fill in the value with the cardinality counter and 15 random alphanumeric characters
|
||||||
value = "{{id}}_{{random 15}}"
|
template = "{{id}}_{{random 15}}"
|
||||||
cardinality = 1000
|
cardinality = 1
|
||||||
has_one = ["env"]
|
has_one = ["env"]
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "env"
|
name = "env"
|
||||||
value = "whatever-environment-{{id}}"
|
template = "whatever-environment-{{id}}"
|
||||||
cardinality = 10
|
cardinality = 10
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "bucket_id"
|
name = "bucket_id"
|
||||||
belongs_to = "org_id"
|
belongs_to = "org_id"
|
||||||
# each bucket will have a unique value so it can be used here to guarantee uniqueness even across orgs
|
# each bucket will have a unique value so it can be used here to guarantee uniqueness even across orgs
|
||||||
value = "{{id}}_{{random 15}}"
|
template = "{{id}}_{{random 15}}"
|
||||||
# For each org, 3 buckets will be generated
|
# For each org, 3 buckets will be generated
|
||||||
cardinality = 3
|
cardinality = 3
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "node_id"
|
name = "node_id"
|
||||||
value = "{{id}}"
|
template = "{{id}}"
|
||||||
cardinality = 100
|
cardinality = 100
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "host"
|
name = "host"
|
||||||
value = "storage-{{node_id.value}}"
|
template = "storage-{{node_id.value}}"
|
||||||
belongs_to = "node_id"
|
belongs_to = "node_id"
|
||||||
cardinality = 1
|
cardinality = 1
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "hostname"
|
name = "hostname"
|
||||||
value = "{{node_id.value}}"
|
template = "{{node_id.value}}"
|
||||||
belongs_to = "node_id"
|
belongs_to = "node_id"
|
||||||
cardinality = 1
|
cardinality = 1
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "partition_id"
|
name = "partition_id"
|
||||||
value = "{{id}}"
|
template = "{{id}}"
|
||||||
cardinality = 10
|
cardinality = 10
|
||||||
|
|
||||||
# makes a tagset so every bucket exists on every node with every partition.
|
# makes a tagset so every bucket exists on every node with every partition.
|
||||||
|
@ -75,16 +75,7 @@ name = "metric-scraper"
|
||||||
|
|
||||||
[[agents.measurements]]
|
[[agents.measurements]]
|
||||||
name = "storage_usage_bucket_cardinality"
|
name = "storage_usage_bucket_cardinality"
|
||||||
# each unique tag set will get an entry in this measurement
|
# TODO: new syntax to make use of tag sets here
|
||||||
# tag_set = "bucket_set"
|
|
||||||
#
|
|
||||||
#[[agents.measurements.tags]]
|
|
||||||
#name = "role"
|
|
||||||
#value = "storage"
|
|
||||||
#
|
|
||||||
#[[agents.measurements.tags]]
|
|
||||||
#name = "url"
|
|
||||||
#value = "http://127.0.0.1:6060/metrics/usage"
|
|
||||||
|
|
||||||
[[agents.measurements.fields]]
|
[[agents.measurements.fields]]
|
||||||
name = "gauge"
|
name = "gauge"
|
||||||
|
|
|
@ -94,7 +94,7 @@ pub struct ValuesSpec {
|
||||||
/// The name of the collection of values
|
/// The name of the collection of values
|
||||||
pub name: String,
|
pub name: String,
|
||||||
/// The handlebars template to create each value in the collection
|
/// The handlebars template to create each value in the collection
|
||||||
pub value: String,
|
pub template: String,
|
||||||
/// How many of these values should be generated. If belongs_to is
|
/// How many of these values should be generated. If belongs_to is
|
||||||
/// specified, each parent will have this many of this value. So
|
/// specified, each parent will have this many of this value. So
|
||||||
/// the total number of these values generated would be parent.len() * self.cardinality
|
/// the total number of these values generated would be parent.len() * self.cardinality
|
||||||
|
@ -125,9 +125,10 @@ impl ValuesSpec {
|
||||||
pub struct TagSetsSpec {
|
pub struct TagSetsSpec {
|
||||||
/// The name of the tag set spec
|
/// The name of the tag set spec
|
||||||
pub name: String,
|
pub name: String,
|
||||||
/// An array of the values to loop through. To reference parent belongs_to or has_one
|
/// An array of the `ValuesSpec` to loop through. To reference parent belongs_to or has_one
|
||||||
/// values, the parent should come first and then the has_one or child next. See the
|
/// values, the parent should come first and then the has_one or child next. Each successive
|
||||||
/// doc for `ForEachValueTag` and its `value` for more detail.
|
/// entry in this array is a nested loop. Multiple has_one and a belongs_to on a parent can
|
||||||
|
/// be traversed.
|
||||||
pub for_each: Vec<String>,
|
pub for_each: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,19 +58,23 @@ pub struct GeneratedValueCollection {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct GeneratedValue {
|
pub struct GeneratedValue {
|
||||||
value: Arc<String>,
|
|
||||||
id: usize,
|
id: usize,
|
||||||
tag_pair: Arc<TagPair>,
|
tag_pair: Arc<TagPair>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct GeneratedTagSets {
|
pub struct GeneratedTagSets {
|
||||||
|
// These map the name of a collection of values to its values. All values will have
|
||||||
|
// an entry in this map. For has_one and child_values, they will have duplicates there
|
||||||
|
// as well to make generating the tag sets possible.
|
||||||
values: BTreeMap<String, Vec<Arc<GeneratedValue>>>,
|
values: BTreeMap<String, Vec<Arc<GeneratedValue>>>,
|
||||||
// each parent-child will have its children stored in this map. The children map
|
// each parent-child will have its children stored in this map. The children map
|
||||||
// the id of the parent to the collection of its children values
|
// the id of the parent to the collection of its children values
|
||||||
child_values: BTreeMap<String, BTreeMap<usize, Vec<Arc<GeneratedValue>>>>,
|
child_values: BTreeMap<String, BTreeMap<usize, Vec<Arc<GeneratedValue>>>>,
|
||||||
// each parent-has_one will have its has_ones stored in this map
|
// each parent-has_one will have its has_ones stored in this map
|
||||||
has_one_values: BTreeMap<String, ParentToHasOnes>,
|
has_one_values: BTreeMap<String, ParentToHasOnes>,
|
||||||
|
// this maps the name of the tag set specified in the spec to the collection of tag
|
||||||
|
// sets that were pre-generated.
|
||||||
tag_sets: BTreeMap<String, Vec<TagSet>>,
|
tag_sets: BTreeMap<String, Vec<TagSet>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,12 +85,6 @@ pub struct ParentToHasOnes {
|
||||||
id_to_has_ones: BTreeMap<usize, BTreeMap<Arc<String>, Arc<GeneratedValue>>>,
|
id_to_has_ones: BTreeMap<usize, BTreeMap<Arc<String>, Arc<GeneratedValue>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct TagSetKey {
|
|
||||||
value: String,
|
|
||||||
tag_key: Arc<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GeneratedTagSets {
|
impl GeneratedTagSets {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn from_spec(spec: &DataSpec) -> Result<Self> {
|
pub fn from_spec(spec: &DataSpec) -> Result<Self> {
|
||||||
|
@ -295,7 +293,7 @@ impl GeneratedTagSets {
|
||||||
spec: &ValuesSpec,
|
spec: &ValuesSpec,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
template
|
template
|
||||||
.register_template_string(&spec.name, &spec.value)
|
.register_template_string(&spec.name, &spec.template)
|
||||||
.context(CantCompileTemplate {
|
.context(CantCompileTemplate {
|
||||||
template: &spec.name,
|
template: &spec.name,
|
||||||
})?;
|
})?;
|
||||||
|
@ -319,7 +317,6 @@ impl GeneratedTagSets {
|
||||||
|
|
||||||
vals.push(Arc::new(GeneratedValue {
|
vals.push(Arc::new(GeneratedValue {
|
||||||
id: i,
|
id: i,
|
||||||
value: Arc::clone(&value),
|
|
||||||
tag_pair: Arc::new(TagPair {
|
tag_pair: Arc::new(TagPair {
|
||||||
key: Arc::clone(&tag_key),
|
key: Arc::clone(&tag_key),
|
||||||
value,
|
value,
|
||||||
|
@ -393,7 +390,7 @@ impl GeneratedTagSets {
|
||||||
let data = json!({
|
let data = json!({
|
||||||
belongs_to: {
|
belongs_to: {
|
||||||
"id": parent.id,
|
"id": parent.id,
|
||||||
"value": &parent.value,
|
"value": &parent.tag_pair.value,
|
||||||
},
|
},
|
||||||
"id": child_value_id,
|
"id": child_value_id,
|
||||||
});
|
});
|
||||||
|
@ -408,7 +405,6 @@ impl GeneratedTagSets {
|
||||||
|
|
||||||
let child_value = Arc::new(GeneratedValue {
|
let child_value = Arc::new(GeneratedValue {
|
||||||
id: child_value_id,
|
id: child_value_id,
|
||||||
value: Arc::clone(&value),
|
|
||||||
tag_pair: Arc::new(TagPair {
|
tag_pair: Arc::new(TagPair {
|
||||||
key: Arc::clone(&tag_key),
|
key: Arc::clone(&tag_key),
|
||||||
value,
|
value,
|
||||||
|
@ -488,7 +484,7 @@ base_seed = "foo"
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "foo"
|
name = "foo"
|
||||||
value = "{{id}}#foo"
|
template = "{{id}}#foo"
|
||||||
cardinality = 3
|
cardinality = 3
|
||||||
|
|
||||||
[[tag_sets]]
|
[[tag_sets]]
|
||||||
|
@ -525,12 +521,12 @@ base_seed = "foo"
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "foo"
|
name = "foo"
|
||||||
value = "{{id}}#foo"
|
template = "{{id}}#foo"
|
||||||
cardinality = 2
|
cardinality = 2
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "bar"
|
name = "bar"
|
||||||
value = "{{id}}-{{foo.id}}-{{foo.value}}"
|
template = "{{id}}-{{foo.id}}-{{foo.value}}"
|
||||||
cardinality = 2
|
cardinality = 2
|
||||||
belongs_to = "foo"
|
belongs_to = "foo"
|
||||||
|
|
||||||
|
@ -572,30 +568,30 @@ base_seed = "foo"
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "foo"
|
name = "foo"
|
||||||
value = "{{id}}-foo"
|
template = "{{id}}-foo"
|
||||||
cardinality = 3
|
cardinality = 3
|
||||||
has_one = ["bar"]
|
has_one = ["bar"]
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "bar"
|
name = "bar"
|
||||||
value = "{{id}}-bar"
|
template = "{{id}}-bar"
|
||||||
cardinality = 2
|
cardinality = 2
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "asdf"
|
name = "asdf"
|
||||||
value = "{{id}}-asdf"
|
template = "{{id}}-asdf"
|
||||||
cardinality = 2
|
cardinality = 2
|
||||||
belongs_to = "foo"
|
belongs_to = "foo"
|
||||||
has_one = ["qwer"]
|
has_one = ["qwer"]
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "jkl"
|
name = "jkl"
|
||||||
value = "{{id}}-jkl"
|
template = "{{id}}-jkl"
|
||||||
cardinality = 2
|
cardinality = 2
|
||||||
|
|
||||||
[[values]]
|
[[values]]
|
||||||
name = "qwer"
|
name = "qwer"
|
||||||
value = "{{id}}-qwer"
|
template = "{{id}}-qwer"
|
||||||
cardinality = 6
|
cardinality = 6
|
||||||
|
|
||||||
[[tag_sets]]
|
[[tag_sets]]
|
||||||
|
|
Loading…
Reference in New Issue