From 3a98ae13c092023fc71f9a8016aaaa0ea408c6b0 Mon Sep 17 00:00:00 2001 From: Scott Trent Date: Mon, 28 Oct 2024 09:54:17 +0900 Subject: [PATCH] update to latest Signed-off-by: Scott Trent --- .gitignore | 1 + samples/impact-framework/README.md | 4 +-- .../offClusterApproach/.trent/README.md | 1 + .../{ => .trent}/htest.yaml | 0 .../.trent/pi1/pi1test.yaml | 28 +++++++++++++++++++ .../offClusterApproach/.trent/pi1/steps.txt | 20 +++++++++++++ .../offClusterApproach/README.md | 15 +++++++--- .../offClusterApproach/ptest.yaml | 2 +- .../offClusterApproach/test/package-lock.json | 8 +++--- .../offClusterApproach/test/package.json | 2 +- .../onClusterApproach/{ => .trent}/htest.yaml | 0 .../onClusterApproach/Dockerfile | 18 ++---------- .../onClusterApproach/README.md | 9 +++++- .../onClusterApproach/ptest.yaml | 2 +- 14 files changed, 80 insertions(+), 30 deletions(-) create mode 100644 samples/impact-framework/offClusterApproach/.trent/README.md rename samples/impact-framework/offClusterApproach/{ => .trent}/htest.yaml (100%) create mode 100644 samples/impact-framework/offClusterApproach/.trent/pi1/pi1test.yaml create mode 100644 samples/impact-framework/offClusterApproach/.trent/pi1/steps.txt rename samples/impact-framework/onClusterApproach/{ => .trent}/htest.yaml (100%) diff --git a/.gitignore b/.gitignore index 0fa175c..31533fb 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ temp-prometheus.yaml c3-susql-config.yaml nohup.out .env +node_modules diff --git a/samples/impact-framework/README.md b/samples/impact-framework/README.md index 277018c..7edd94e 100644 --- a/samples/impact-framework/README.md +++ b/samples/impact-framework/README.md @@ -1,8 +1,8 @@ # Using SusQL with the Green Software Foundation's Impact Framework A large design point in using SusQL data with the Green Software Foundation's -Impact Framework is whether to run in a container ON the cluster, or run on a machine -external to the cluster. +Impact Framework is whether to run in a container ON the cluster with SusQL, or run +on a machine external to the cluster. This directory contains two directories with experiments into both approaches: diff --git a/samples/impact-framework/offClusterApproach/.trent/README.md b/samples/impact-framework/offClusterApproach/.trent/README.md new file mode 100644 index 0000000..86478a9 --- /dev/null +++ b/samples/impact-framework/offClusterApproach/.trent/README.md @@ -0,0 +1 @@ +experimentation... diff --git a/samples/impact-framework/offClusterApproach/htest.yaml b/samples/impact-framework/offClusterApproach/.trent/htest.yaml similarity index 100% rename from samples/impact-framework/offClusterApproach/htest.yaml rename to samples/impact-framework/offClusterApproach/.trent/htest.yaml diff --git a/samples/impact-framework/offClusterApproach/.trent/pi1/pi1test.yaml b/samples/impact-framework/offClusterApproach/.trent/pi1/pi1test.yaml new file mode 100644 index 0000000..7b78b86 --- /dev/null +++ b/samples/impact-framework/offClusterApproach/.trent/pi1/pi1test.yaml @@ -0,0 +1,28 @@ +name: prometheus importer test +description: simple susql demo invoking prometheus-importer plugin +tags: null +initialize: + plugins: + prometheus-importer: + method: PrometheusImporter + path: 'https://github.com/Shivani-G/prometheus-importer' + global-config: + step: '1h' + start: '2024-09-16T23:50:30.000Z' + end: '2024-10-16T00:00:30.000Z' + query: 'rate(susql_container_joules_total)[1m])' + metricLabels: + - name + metricName: 'energy' + defaultLabels: + duration: 3600 + cloud/vendor: 'ibm' + cloud/instance-type: 'medium' + outputs: + - yaml +tree: + children: + child: + pipeline: + - prometheus-importer + inputs: diff --git a/samples/impact-framework/offClusterApproach/.trent/pi1/steps.txt b/samples/impact-framework/offClusterApproach/.trent/pi1/steps.txt new file mode 100644 index 0000000..28ed6cd --- /dev/null +++ b/samples/impact-framework/offClusterApproach/.trent/pi1/steps.txt @@ -0,0 +1,20 @@ +# in this directory +npm init -y +npm install -g husky +npm install -g @grnsft/if +# npm remove -g "https://github.com/trent-s/prometheus-importer" +npm remove -g prometheus-importer +npm remove prometheus-importer +npm install -g "https://github.com/Shivani-G/prometheus-importer" +npm update +echo "BEARER_TOKEN="$(oc whoami -t) >.env +echo HOST=https://$(oc get routes -n openshift-monitoring thanos-querier -o jsonpath='{.status.ingress[0].host}') >>.env +if-run --manifest pi1test.yaml --debug + + + + +## troubleshootign +# npm cache verify +# npm install npm@latest -g + diff --git a/samples/impact-framework/offClusterApproach/README.md b/samples/impact-framework/offClusterApproach/README.md index b54f065..2748b4d 100644 --- a/samples/impact-framework/offClusterApproach/README.md +++ b/samples/impact-framework/offClusterApproach/README.md @@ -1,20 +1,27 @@ # Using SusQL with the Green Software Foundation's Impact Framework This particular experiment was performed using a recent RHEL 9 x86 machine, -however, any OS that supports a sufficiently recent version of nodejs should +however, any OS that supports a sufficiently recent version of `nodejs` should work in principle. +The key to importing data from SusQL is a Prometheus Importer Plugin for the GSF Impact Framework. +Currently there are two such plugins described in the (IF Explorer)[https://explorer.if.greensoftware.foundation]: +- (`Prometheus Importer`)[https://github.com/andreic94/if-prometheus-importer/blob/main/README.md] by `andreic94`, et al. +- (`prometheus-importer`)[https://github.com/Shivani-G/prometheus-importer/blob/main/README.md] by `Shibani-G`. + +The following is an approach using the later plugin: + ### steps - Ensure that you are logged into your cluster and can use the `oc` (or `kubectl` command). - Make sure that a recent version of `node` is installed. (This test used v22.9.0) - Install Impact Framework - `npm install -g @grnsft/if` - Install Prometheus Importer - - `npm install -g "https://github.com/trent-s/prometheus-importer"` -- Update, just to be sure: + - `npm install -g "https://github.com/Shivani-G/prometheus-importer"` +- Update, just to be sure: (Starting from the directory that contains this README...) - `cd test; npm update; cd -` -- Create required credential file, and attempt to use prometheus-importer: +- Create required credential file, and attempt to use prometheus-importer: (Starting from the directory that contains this README...) ``` cd test echo "BEARER_TOKEN="$(oc whoami -t) >.env diff --git a/samples/impact-framework/offClusterApproach/ptest.yaml b/samples/impact-framework/offClusterApproach/ptest.yaml index 3af2d41..ef96335 100644 --- a/samples/impact-framework/offClusterApproach/ptest.yaml +++ b/samples/impact-framework/offClusterApproach/ptest.yaml @@ -5,7 +5,7 @@ initialize: plugins: prometheus-importer: method: PrometheusImporter - path: 'https://github.com/trent-s/prometheus-importer' + path: 'https://github.com/Shivani-G/prometheus-importer' config: step: '1h' start: '2024-09-16T23:50:30.000Z' diff --git a/samples/impact-framework/offClusterApproach/test/package-lock.json b/samples/impact-framework/offClusterApproach/test/package-lock.json index 98ee414..1ff56e9 100644 --- a/samples/impact-framework/offClusterApproach/test/package-lock.json +++ b/samples/impact-framework/offClusterApproach/test/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "prometheus-importer": "github:trent-s/prometheus-importer" + "prometheus-importer": "github:Shivani-G/prometheus-importer" } }, "node_modules/@grnsft/if-core": { @@ -74,14 +74,14 @@ } }, "node_modules/prometheus-importer": { - "version": "0.2.2", - "resolved": "git+ssh://git@github.com/trent-s/prometheus-importer.git#00b87d68d4d5351ba3768d9a70c9e0f6e3f199bd", + "version": "v0.1.1", + "resolved": "git+ssh://git@github.com/Shivani-G/prometheus-importer.git#861a0a7ef3e5f81ec2904838f0b6905a94686a0d", "license": "MIT", "dependencies": { "@grnsft/if-core": "^0.0.7", "dotenv": "16.3.1", "node-fetch-commonjs": "^3.3.2", - "typescript": "^5.6.3", + "typescript": "^5.5.2", "zod": "^3.23.8" }, "engines": { diff --git a/samples/impact-framework/offClusterApproach/test/package.json b/samples/impact-framework/offClusterApproach/test/package.json index 1ed8e6f..78e39f8 100644 --- a/samples/impact-framework/offClusterApproach/test/package.json +++ b/samples/impact-framework/offClusterApproach/test/package.json @@ -10,6 +10,6 @@ "license": "ISC", "description": "", "dependencies": { - "prometheus-importer": "github:trent-s/prometheus-importer" + "prometheus-importer": "github:Shivani-G/prometheus-importer" } } diff --git a/samples/impact-framework/onClusterApproach/htest.yaml b/samples/impact-framework/onClusterApproach/.trent/htest.yaml similarity index 100% rename from samples/impact-framework/onClusterApproach/htest.yaml rename to samples/impact-framework/onClusterApproach/.trent/htest.yaml diff --git a/samples/impact-framework/onClusterApproach/Dockerfile b/samples/impact-framework/onClusterApproach/Dockerfile index 08b9b11..aa18a52 100644 --- a/samples/impact-framework/onClusterApproach/Dockerfile +++ b/samples/impact-framework/onClusterApproach/Dockerfile @@ -19,20 +19,6 @@ npm install -g npm@10.9.0 && \ echo " --- Finished node update" && \ npm install -g typescript rimraf husky @grnsft/if && \ echo " --- Finished if install" && \ -# npm install -g @types/node && \ -# echo " --- Finished @types/node install" && \ -# git clone https://github.com/Green-Software-Foundation/if.git && cd if && npm install -g && npm install && npm link && cd - && \ -# echo " --- Finished IF npm link" && \ -# npm install -g "https://github.com/trent-s/prometheus-importer" && \ -# echo " --- Finished PI install" && \ -# git clone https://github.com/trent-s/prometheus-importer.git && cd prometheus-importer && \ -# npm install --save-dev @types/node && npm run build && npm install -g && npm install && npm link && cd - && \ -# echo " --- Finished cloning PI" && \ -# npm install -g "https://github.com/trent-s/hello-plugin" && \ -# git clone https://github.com/trent-s/hello-plugin.git && cd hello-plugin && \ -# npm install --save-dev @types/node && npm run build && npm install -g && npm install && npm link && cd - && \ -# cd if && npm link hello-plugin && cd - && \ -# echo " --- Finished cloning and initializing hello-plugin" && \ -# cd if && npm link prometheus-importer && cd - && \ -# echo " --- Finished last link " && \ +npm install -g "https://github.com/Shivani-G/prometheus-importer" && \ +echo " --- Finished PI install" && \ chown -R 1000:1000 /work /usr/local/ diff --git a/samples/impact-framework/onClusterApproach/README.md b/samples/impact-framework/onClusterApproach/README.md index f72c9c2..e85bc87 100644 --- a/samples/impact-framework/onClusterApproach/README.md +++ b/samples/impact-framework/onClusterApproach/README.md @@ -5,8 +5,15 @@ Green Software Foundation's Impact Framework using a slightly modified version of the PrometheusImporter plugin. The fundamental focus of this particular approach is to run entirely on Cluster, and is based on OpenShift. +The key to importing data from SusQL is a Prometheus Importer Plugin for the GSF Impact Framework. +Currently there are two such plugins described in the (IF Explorer)[https://explorer.if.greensoftware.foundation]: +- (`Prometheus Importer`)[https://github.com/andreic94/if-prometheus-importer/blob/main/README.md] by `andreic94`, et al. +- (`prometheus-importer`)[https://github.com/Shivani-G/prometheus-importer/blob/main/README.md] by `Shibani-G`. + +This approach uses the later plugin. + However, this is a work in progress related to an apparent limitation -in the use of certain required nodejs functionality within a container. +in the use of certain required global`nodejs` functionality within a container. ### Using prebuilt container image: - Ensure that you are logged into your cluster, then start the Impact Framework container: `oc apply -f impact-framework.yaml` diff --git a/samples/impact-framework/onClusterApproach/ptest.yaml b/samples/impact-framework/onClusterApproach/ptest.yaml index 3af2d41..ef96335 100644 --- a/samples/impact-framework/onClusterApproach/ptest.yaml +++ b/samples/impact-framework/onClusterApproach/ptest.yaml @@ -5,7 +5,7 @@ initialize: plugins: prometheus-importer: method: PrometheusImporter - path: 'https://github.com/trent-s/prometheus-importer' + path: 'https://github.com/Shivani-G/prometheus-importer' config: step: '1h' start: '2024-09-16T23:50:30.000Z'