From 5b3889aaa4d4781dbbf3d4a97a68c52da851780d Mon Sep 17 00:00:00 2001 From: bl4cksousou <34798525+bl4cksousou@users.noreply.github.com> Date: Fri, 21 Jul 2023 15:06:40 +0200 Subject: [PATCH 1/5] Create generate.sh This code generates the API call and saves it to send.sh --- submit_metric_with_multible_hosts/generate.sh | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 submit_metric_with_multible_hosts/generate.sh diff --git a/submit_metric_with_multible_hosts/generate.sh b/submit_metric_with_multible_hosts/generate.sh new file mode 100644 index 0000000..2ed586a --- /dev/null +++ b/submit_metric_with_multible_hosts/generate.sh @@ -0,0 +1,45 @@ +cat > send.sh <> send.sh <> send.sh +else +echo "," >> send.sh +fi +i=$((i+1)) +done < <(tail -n +2 data.csv) +echo "}" >> send.sh +echo "EOF" >> send.sh +bash send.sh From 198066cc39d8eff8e464f0bbb714a16a1b38ed1c Mon Sep 17 00:00:00 2001 From: bl4cksousou <34798525+bl4cksousou@users.noreply.github.com> Date: Fri, 21 Jul 2023 15:09:30 +0200 Subject: [PATCH 2/5] Create data.csv This is a csv file that contains the list of hostnames along with the metric value and the timestamp. --- submit_metric_with_multible_hosts/data.csv | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 submit_metric_with_multible_hosts/data.csv diff --git a/submit_metric_with_multible_hosts/data.csv b/submit_metric_with_multible_hosts/data.csv new file mode 100644 index 0000000..47bf73f --- /dev/null +++ b/submit_metric_with_multible_hosts/data.csv @@ -0,0 +1,5 @@ +hostname,value,timestamp +A_host,6,1689773651 +B_host,4,1689773651 +C_host,2,1689773651 +D_host,2.5,1689773651 From b3242668dac3f509461b07d1b7a667999db74ecc Mon Sep 17 00:00:00 2001 From: bl4cksousou <34798525+bl4cksousou@users.noreply.github.com> Date: Fri, 21 Jul 2023 15:27:42 +0200 Subject: [PATCH 3/5] Create README.md --- submit_metric_with_multible_hosts/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 submit_metric_with_multible_hosts/README.md diff --git a/submit_metric_with_multible_hosts/README.md b/submit_metric_with_multible_hosts/README.md new file mode 100644 index 0000000..f5c2cd7 --- /dev/null +++ b/submit_metric_with_multible_hosts/README.md @@ -0,0 +1,19 @@ +# sandbox/vagrant/Security/cws/agent_rules + +# code generation Icon + +## What does this script do + +When using the V2 metric submission API endpoint (https://docs.datadoghq.com/api/latest/metrics/#submit-metrics) users cannot specify multiple hots tags on the same `series` parameter. + +Instead, we need to define a seperate `series` for each hostname. + +This could be a tedious process especially if we have a large number of hosts with different metric value and timestamps. + +`generate.sh` will automatically create a ready to use script that contains the proper API call to submit multiple data points for multiple hosts in different timestamps. + +## Instructions + +Before launching the `generate.sh` script, make sure to fill up the `data.csv` file with the list of host names, their metric values and their timestamp accordingly. + +Once done you can launch the `generate.sh` script which will automatically generate another script `send.sh` which could be executed to submit the metrics. From 216ec83fa4e01584ea5d4c968c34475ea79019a6 Mon Sep 17 00:00:00 2001 From: bl4cksousou <34798525+bl4cksousou@users.noreply.github.com> Date: Fri, 21 Jul 2023 15:28:02 +0200 Subject: [PATCH 4/5] Update README.md --- submit_metric_with_multible_hosts/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/submit_metric_with_multible_hosts/README.md b/submit_metric_with_multible_hosts/README.md index f5c2cd7..e39b1b2 100644 --- a/submit_metric_with_multible_hosts/README.md +++ b/submit_metric_with_multible_hosts/README.md @@ -1,5 +1,3 @@ -# sandbox/vagrant/Security/cws/agent_rules - # code generation Icon ## What does this script do From 7c7ef2f42533bc461f8238bba7a8cf925ae8a641 Mon Sep 17 00:00:00 2001 From: bl4cksousou <34798525+bl4cksousou@users.noreply.github.com> Date: Fri, 21 Jul 2023 15:33:59 +0200 Subject: [PATCH 5/5] Update README.md --- submit_metric_with_multible_hosts/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/submit_metric_with_multible_hosts/README.md b/submit_metric_with_multible_hosts/README.md index e39b1b2..dae28aa 100644 --- a/submit_metric_with_multible_hosts/README.md +++ b/submit_metric_with_multible_hosts/README.md @@ -15,3 +15,5 @@ This could be a tedious process especially if we have a large number of hosts wi Before launching the `generate.sh` script, make sure to fill up the `data.csv` file with the list of host names, their metric values and their timestamp accordingly. Once done you can launch the `generate.sh` script which will automatically generate another script `send.sh` which could be executed to submit the metrics. + +> **_NOTE:_** Please make sure to replace the API key and the endpoint URL accordingly.