diff --git a/docs/docs/examples-tutorials/recipes/synthetic-monitoring-trace-based-api-tests.mdx b/docs/docs/examples-tutorials/recipes/synthetic-monitoring-trace-based-api-tests.mdx index 7539dbefa5..98c3eff554 100644 --- a/docs/docs/examples-tutorials/recipes/synthetic-monitoring-trace-based-api-tests.mdx +++ b/docs/docs/examples-tutorials/recipes/synthetic-monitoring-trace-based-api-tests.mdx @@ -36,9 +36,7 @@ To view the full guide on how to configure the Node.js app, view [this recipe](/ **Tracetest Account**: - Sign up to [`app.tracetest.io`](https://app.tracetest.io) or follow the [get started](/getting-started/installation) docs. -- Create an [environment](/concepts/environments). -- Create an [environment token](/concepts/environment-tokens). -- Have access to the environment's [agent API key](/configuration/agent). +- Have access to the environment's [agent API key](https://app.tracetest.io/retrieve-token). **Docker**: Have [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine. @@ -56,76 +54,55 @@ cd tracetest/examples/quick-start-nodejs-synthetic-monitoring Follow these instructions to run the quick start: 1. Copy the `.env.template` file to `.env`. -2. Log into the [Tracetest app](https://app.tracetest.io/). -3. This example is configured to use the OpenTelemetry Tracing Backend. Ensure the environment you will be utilizing to run this example is also configured to use the OpenTelemetry Tracing Backend by clicking on Settings, Tracing Backend, OpenTelemetry, Save. -4. Fill out the [token](https://docs.tracetest.io/concepts/environment-tokens) and [API key](https://docs.tracetest.io/concepts/agent) details by editing your `.env` file. You can find these values in the Settings area for your environment. -5. Run `docker compose up -d`. -6. Configure your CLI with `tracetest configure -t `. -7. Apply the Tracetest Monitor with `tracetest apply monitor -f tracetest-synthetic-monitor.yaml`. This will start running the `./tracetest-test-api.yaml` test every minute. -8. Run tests manually from the CLI with `tracetest run test -f ./tracetest-test-api.yaml` or from the Tracetest Web UI by accessing the app with the URL `http://app:8080/books`. +2. Fill out the [TRACETEST_TOKEN and ENVIRONMENT_ID](https://app.tracetest.io/retrieve-token) details by editing your `.env` file. +3. Run `docker compose run tracetest-run`. +4. Follow the links in the output to view the test results. -Follow along with the sections below for a detailed breakdown of what the example you just ran did and how it works. +Follow along with the sections below for an in detail breakdown of what the example you just ran did and how it works. ## Running the Node.js App To start the full setup, run the following command: ```bash -docker compose up -d +docker compose run tracetest-run ``` ## Run Tracetest Tests -1. Open [Tracetest](https://app.tracetest.io/) -2. Start creating tests! Make sure to use the `http://app:8080/books` URL in your test creation. -3. To trigger tests in the CLI, first [install the CLI](/cli/cli-installation-reference), [configure it](/cli/configuring-your-cli), and [run a test](/cli/running-tests). From the root of the quick start directory, run: +This will: +1. Start the Node.js app, the OpenTelemetry Collector, and send the traces to Tempo. +2. Start the Tracetest Agent. +3. Configure the tracing backend and create the monitor and tests in your environment. +4. Run the tests. -```bash -tracetest configure -t -tracetest run test -f ./tracetest-test-api.yaml -``` - -Here's a sample of a failed test run, which happens if you use this selector and assertion pair. - -Selector: -``` -span[tracetest.span.type="general" name="Books List"] -``` - -Assertion: -``` -attr: books.list.count = 4 -``` - -![assertion](https://res.cloudinary.com/djwdcmwdz/image/upload/v1715607148/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_56b66bc6e1a1cbbd_test_e9CCQuLSg_run_3_selectedAssertion_0_selectedSpan_d0c03aa5d02b9975_uqhhwl.png) - -It fails because `books.length` is equal to `3`. +Open the URL and start creating tests! Make sure to use the `http://app:8080/` URL in your test creation, because your Node.js app and Tracetest are in the same network. ## Run Synthetic Monitoring -You can apply the Tracetest Monitor with the CLI. +The monitor will be automatically applied when running this example. You can find the Tracetest Monitor Definition and apply it directly yourself using the CLI. ```bash -tracetest apply monitor -f tracetest-synthetic-monitor.yaml +tracetest apply monitor -f ./resources/monitor.yaml ``` -This will start running the `./tracetest-test-api.yaml` test every minute. +This will start running the `./resources/monitor.yaml` test every minute. With the Web UI follow these steps to create a monitor. 1. Select `Monitors` in the [Tracetest](https://app.tracetest.io/) sidebar. 2. Create a Monitor. Select a schedule and toggle the enable monitor switch. - ![create a monitor](https://res.cloudinary.com/djwdcmwdz/image/upload/v1721921382/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_page_1_guf2id.png) + ![create a monitor](https://res.cloudinary.com/djwdcmwdz/image/upload/v1721921382/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_page_1_guf2id.png) 3. Select the test you want to add to the Monitor. - ![select tests for monitor](https://res.cloudinary.com/djwdcmwdz/image/upload/v1721921383/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_page_1_1_dsbb1k.png) + ![select tests for monitor](https://res.cloudinary.com/djwdcmwdz/image/upload/v1721921383/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_page_1_1_dsbb1k.png) 4. Select the webhook you want to notify. - ![select webhook](https://res.cloudinary.com/djwdcmwdz/image/upload/v1721921382/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_page_1_2_rzz5vm.png) + ![select webhook](https://res.cloudinary.com/djwdcmwdz/image/upload/v1721921382/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_page_1_2_rzz5vm.png) 5. Click `Create` and you will see the Monitor run. - ![monitor run overview](https://res.cloudinary.com/djwdcmwdz/image/upload/v1721921382/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_page_1_3_pktmr0.png) + ![monitor run overview](https://res.cloudinary.com/djwdcmwdz/image/upload/v1721921382/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_page_1_3_pktmr0.png) 6. To view the YAML definition for the Monitor, click `Automate`. - ![monitor automate overview](https://res.cloudinary.com/djwdcmwdz/image/upload/v1721921383/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_page_1_4_ysjbnx.png) + ![monitor automate overview](https://res.cloudinary.com/djwdcmwdz/image/upload/v1721921383/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_page_1_4_ysjbnx.png) -With this setup, your Monitor will trigger the `Books list with availability` test, defined in `./tracetest-test-api.yaml`, every 5 minutes. +With this setup, your Monitor will trigger the `Books list with availability` test, defined in `./resources/test.yaml`, every 5 minutes. ## Learn More diff --git a/docs/docs/examples-tutorials/recipes/synthetic-monitoring-trace-based-playwright-tests.mdx b/docs/docs/examples-tutorials/recipes/synthetic-monitoring-trace-based-playwright-tests.mdx index 715899e292..404b6f0e54 100644 --- a/docs/docs/examples-tutorials/recipes/synthetic-monitoring-trace-based-playwright-tests.mdx +++ b/docs/docs/examples-tutorials/recipes/synthetic-monitoring-trace-based-playwright-tests.mdx @@ -48,9 +48,7 @@ Benefits of using traces as test specs alongside synthetic monitoring: **Tracetest Account**: - Sign up to [`app.tracetest.io`](https://app.tracetest.io) or follow the [get started](/getting-started/installation) docs. -- Create an [environment](/concepts/environments). -- Create an [environment token](/concepts/environment-tokens) with **admin role**. -- Copy the environment id to your clipboard. +- Have access to the environment's [agent API key](https://app.tracetest.io/retrieve-token). **Docker**: Have [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine. @@ -67,13 +65,12 @@ git clone https://github.com/kubeshop/tracetest cd tracetest/examples/tracetest-synthetic-monitoring ``` -Follow these instructions to run the example: +Follow these instructions to run the quick start: -1. Log into the [Tracetest app](https://app.tracetest.io/). -2. Copy the `.env.template` file to `.env`. -3. Fill out the [TRACETEST_API_TOKEN](/concepts/environment-tokens) and [TRACETEST_ENVIRONMENT_ID](/concepts/agent) details by editing your `.env` file. You can find these values in the Settings area for your environment. -4. Run `docker compose run tracetest-apply`. -5. Follow the link in the terminal with the results to view the Monitor run. +1. Copy the `.env.template` file to `.env`. +2. Fill out the [TRACETEST_TOKEN and ENVIRONMENT_ID](https://app.tracetest.io/retrieve-token) details by editing your `.env` file. +3. Run `docker compose run tracetest-run`. +4. Follow the links in the output to view the test results. ## Project Structure @@ -88,8 +85,9 @@ docker-compose.yaml /resources apply.sh datastore.yaml - import-pokemon.yaml + test.yaml script.js + monitor.yaml ``` The [Pokeshop Demo App](/live-examples/pokeshop/overview) is a complete example of a distributed application using different back-end and front-end services. We will be launching it and running tests against it as part of this example. @@ -103,7 +101,7 @@ The example provisions the following resources: ### Import Pokemon Test -```yaml title="resources/import-pokemon.yaml" +```yaml title="resources/test.yaml" type: Test spec: id: import-pokemon @@ -227,122 +225,88 @@ apply() { apply ``` +```bash title="resources/run.sh" +#!/bin/sh + +set -e + +TOKEN=$TRACETEST_TOKEN +ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID + +run() { + echo "Configuring Tracetest" + tracetest configure --token $TOKEN --environment $ENVIRONMENT_ID + + echo "Running Trace-Based Tests..." + tracetest run test -f /resources/test.yaml + tracetest list monitor +} + +run +``` + ## Setting the Environment Variables -Copy the `.env.template` file to `.env` and add the Tracetest API token and environment id to the `TRACETEST_API_TOKEN` and `TRACETEST_ENVIRONMENT_ID` variables. +Copy the `.env.template` file to `.env` and add the Tracetest API token and environment id to the `TRACETEST_TOKEN` and `TRACETEST_ENVIRONMENT_ID` variables. ## Running the Full Example -Creating the resources is automated for you. You only need to run the following command: +Creating the resources and running the tests is automated for you. You only need to run the following command: ```bash -docker compose run tracetest-apply +docker compose run tracetest-run ``` -This command will run the `apply.sh` script to provision the resources and create a synthetic monitor. - ## Viewing the Created Resources -The output from the Tracetest resource apply script should be visible in the console log after running the `apply` command. +The output from the Tracetest resource run script should be visible in the console log after running the `run` command. ```bash title="Output" +WARN[0000] /Users/oscar/Documents/kubeshop/t/examples/tracetest-synthetic-monitoring/docker-compose.yaml: `version` is obsolete [+] Running 2/2 - ✔ api Pulled 2.4s - ✔ worker Pulled 2.6s -[+] Creating 8/0 - ✔ Container tracetest-synthetic-monitoring-playwright-engine-queue-1 Running 0.0s - ✔ Container tracetest-synthetic-monitoring-playwright-engine-postgres-1 Running 0.0s - ✔ Container tracetest-synthetic-monitoring-playwright-engine-cache-1 Running 0.0s - ✔ Container tracetest-synthetic-monitoring-playwright-engine-otel-collector-1 Running 0.0s - ✔ Container tracetest-synthetic-monitoring-playwright-engine-jaeger-1 Running 0.0s - ✔ Container tracetest-synthetic-monitoring-playwright-engine-tracetest-agent-1 Running 0.0s - ✔ Container tracetest-synthetic-monitoring-playwright-engine-worker-1 Running 0.0s - ✔ Container tracetest-synthetic-monitoring-playwright-engine-api-1 Running 0.0s -[+] Running 3/3 - ✔ Container tracetest-synthetic-monitoring-playwright-engine-queue-1 Hea... 1.0s - ✔ Container tracetest-synthetic-monitoring-playwright-engine-postgres-1 Healthy 1.0s - ✔ Container tracetest-synthetic-monitoring-playwright-engine-cache-1 Hea... 1.0s + ✔ api Pulled 0.8s + ✔ worker Pulled 1.1s +[+] Creating 9/9 + ✔ Container tracetest-synthetic-monitoring-playwright-engine-otel-collector-1 Running 0.0s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-queue-1 Running 0.0s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-postgres-1 Running 0.0s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-jaeger-1 Running 0.0s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-cache-1 Running 0.0s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-worker-1 Running 0.0s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-tracetest-agent-1 Recreated 0.1s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-api-1 Running 0.0s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-tracetest-apply-1 Recreated 0.1s +[+] Running 6/6 + ✔ Container tracetest-synthetic-monitoring-playwright-engine-tracetest-agent-1 Started 0.3s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-queue-1 Healthy 1.0s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-postgres-1 Healthy 1.0s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-cache-1 Healthy 1.0s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-api-1 Healthy 0.5s + ✔ Container tracetest-synthetic-monitoring-playwright-engine-tracetest-apply-1 Started 0.1s [+] Running 2/2 - ✔ api Pulled 1.8s - ✔ worker Pulled 1.9s + ✔ worker Pulled 1.0s + ✔ api Pulled 0.9s Configuring Tracetest SUCCESS Successfully configured Tracetest CLI -Applying Resources -type: DataStore -spec: - id: current - name: jaeger - type: jaeger - default: true - createdAt: 2024-05-13T14:22:27.325353Z - jaeger: - endpoint: jaeger:16685 - headers: - "": "" - tls: - insecure: true - -type: Test -spec: - id: import-pokemon - name: Import Pokemon - trigger: - type: playwrightengine - playwrightEngine: - target: http://api:8081 - script: "const { expect } = require(\"@playwright/test\");\n\nasync function addPokemon(page) {\n expect(await page.getByText(\"Pokeshop\")).toBeTruthy();\n\n await page.click(\"text=Add\");\n\n await page.getByLabel(\"Name\").fill(\"Charizard\");\n await page.getByLabel(\"Type\").fill(\"Flying\");\n await page\n .getByLabel(\"Image URL\")\n .fill(\"https://upload.wikimedia.org/wikipedia/en/1/1f/Pok%C3%A9mon_Charizard_art.png\");\n await page.getByRole(\"button\", { name: \"OK\", exact: true }).click();\n}\n\nasync function deletePokemon(page) {\n expect(await page.getByText(\"Pokeshop\")).toBeTruthy();\n\n await page.locator('[data-cy=\"pokemon-list\"]');\n await page.locator('[data-cy=\"pokemon-card\"]').first().click();\n await page.locator('[data-cy=\"pokemon-card\"] [data-cy=\"delete-pokemon-button\"]').first().click();\n}\n\nasync function importPokemon(page) {\n expect(await page.getByText(\"Pokeshop\")).toBeTruthy();\n\n await page.click(\"text=Import\");\n await page.getByLabel(\"ID\").fill(\"143\");\n\n await Promise.all([\n page.waitForResponse((resp) => resp.url().includes(\"/pokemon/import\") && resp.status() === 200),\n page.getByRole(\"button\", { name: \"OK\", exact: true }).click(),\n ]);\n}\n\nmodule.exports = { addPokemon, deletePokemon, importPokemon };\n" - method: importPokemon - specs: - - selector: span[tracetest.span.type="general" name="documentLoad"] - name: Document Load Should be fast - assertions: - - attr:tracetest.span.duration < 500ms - - selector: span[tracetest.span.type="http" http.scheme="http"] - name: All HTTP request should return 200 - assertions: - - attr:http.status_code = 200 - - selector: span[tracetest.span.type="messaging" name="queue.synchronizePokemon process" messaging.system="rabbitmq" messaging.destination="queue.synchronizePokemon" messaging.operation="process"] - name: The worker should be processed - assertions: - - attr:tracetest.selected_spans.count = 1 - - selector: span[tracetest.span.type="database"] - name: "All Database Spans: Processing time is less than 100ms" - assertions: - - attr:tracetest.span.duration < 250ms - -type: Monitor -spec: - id: playwright-monitor - name: Playwright Synthetic Monitor - enabled: true - variableSetId: "" - tests: - - import-pokemon - schedule: - cron: "*/5 * * * *" - timeZone: Etc/UTC - alerts: - - id: slack-webhook-message - type: webhook - webhook: - body: "{\n \"text\": \"Monitor ${.Monitor.Name} has failed, follow the link to find the <${.URL}|results>\"\n}" - method: POST - url: - headers: - - key: Content-Type - value: application/json - events: - - FAILED - - ID NAME VERSION RUNS LAST RUN TIME LAST RUN STATE URL ----------------------- --------------------------------- --------- ------ --------------------- ---------------- ------------------------------------------------------- - playwright-monitor Playwright Synthetic Monitor 1 0 https://api.tracetest.io/monitor/playwright-monitor-3 +Running Trace-Based Tests... +✔ RunGroup: #2c3uThCSg (https://app.tracetest.io/organizations/ttorg_ced62e34638d965e/environments/ttenv_b42fa137465c6e04/run/2c3uThCSg) + Summary: 1 passed, 0 failed, 0 pending + ✔ Import Pokemon (https://app.tracetest.io/organizations/ttorg_ced62e34638d965e/environments/ttenv_b42fa137465c6e04/test/import-pokemon/run/66/test) - trace id: f09a1370ec7a6178aa9ba398f05c2f0f + ✔ Document Load Should be fast + ✔ All HTTP request should return 200 + ✔ The worker should be processed + ✔ All Database Spans: Processing time is less than 100ms + + ID NAME VERSION RUNS LAST RUN TIME LAST RUN STATE URL +-------------------- ------------------------------- --------- ------ --------------------- ---------------- ----------------------------------------------------- + playwright-monitor Playwright Synthetic Monitor 1 0 https://api.tracetest.io/monitor/playwright-monitor + JtFYYc9SR Quick Start Synthetic Monitor 4 6 2024-08-15 19:01:53 https://api.tracetest.io/monitor/JtFYYc9SR ``` ## Running Synthetic Monitoring 1. Select `Monitors` in the [Tracetest](https://app.tracetest.io/) sidebar. -2. You'll see the Monitor that was created in the `apply` script. +2. You'll see the Monitor that was created in the `run` script. ![apply script monitor](https://res.cloudinary.com/djwdcmwdz/image/upload/v1722252986/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_8fca16a31b8b6e24_monitors_oazwzc.png) 3. It will start running based on the schedule you selected. With this setup, your Monitor will trigger the Playwright test every 5 minutes. diff --git a/examples/quick-start-nodejs-synthetic-monitoring/.env.template b/examples/quick-start-nodejs-synthetic-monitoring/.env.template index 978cdba4d9..ae9980a40b 100644 --- a/examples/quick-start-nodejs-synthetic-monitoring/.env.template +++ b/examples/quick-start-nodejs-synthetic-monitoring/.env.template @@ -1,6 +1,9 @@ +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="" +TRACETEST_ENVIRONMENT_ID="" + # GRPC OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="http://tracetest-agent:4317/" # or, use HTTP # OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="http://tracetest-agent:4318/v1/traces" -TRACETEST_API_KEY="" -TRACETEST_API_TOKEN="" diff --git a/examples/quick-start-nodejs-synthetic-monitoring/Dockerfile.tracetest b/examples/quick-start-nodejs-synthetic-monitoring/Dockerfile.tracetest new file mode 100644 index 0000000000..883f239155 --- /dev/null +++ b/examples/quick-start-nodejs-synthetic-monitoring/Dockerfile.tracetest @@ -0,0 +1,11 @@ +FROM alpine + +WORKDIR /app +ARG TRACETEST_IMAGE_VERSION=v1.4.0 + +RUN apk --update add bash jq curl +RUN curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash -s -- $TRACETEST_IMAGE_VERSION + +WORKDIR /resources + +ENTRYPOINT ["echo", "Tracetest CLI installed"] diff --git a/examples/quick-start-nodejs-synthetic-monitoring/docker-compose.yaml b/examples/quick-start-nodejs-synthetic-monitoring/docker-compose.yaml index 1447205aaf..3663335c13 100644 --- a/examples/quick-start-nodejs-synthetic-monitoring/docker-compose.yaml +++ b/examples/quick-start-nodejs-synthetic-monitoring/docker-compose.yaml @@ -1,4 +1,4 @@ -version: '3' +version: "3" services: app: image: quick-start-nodejs @@ -8,6 +8,9 @@ services: - "8080:8080" environment: - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT} + depends_on: + availability: + condition: service_started availability: image: quick-start-nodejs-availability @@ -21,11 +24,43 @@ services: # Cloud-based Managed Tracetest tracetest-agent: image: kubeshop/tracetest-agent:latest - command: - - "--mode=verbose" environment: - # Find the Agent API Key here: https://docs.tracetest.io/configuration/agent - - TRACETEST_API_KEY=${TRACETEST_API_KEY} - ports: - - 4317:4317 - - 4318:4318 + # Get the required information here: https://app.tracetest.io/retrieve-token + - TRACETEST_API_KEY=${TRACETEST_TOKEN} + - TRACETEST_ENVIRONMENT_ID=${TRACETEST_ENVIRONMENT_ID} + + tracetest-apply: + build: + dockerfile: Dockerfile.tracetest + volumes: + - ./resources:/resources + environment: + TRACETEST_TOKEN: ${TRACETEST_TOKEN} + TRACETEST_ENVIRONMENT_ID: ${TRACETEST_ENVIRONMENT_ID} + entrypoint: + - bash + - /resources/apply.sh + networks: + default: null + depends_on: + app: + condition: service_started + tracetest-agent: + condition: service_started + + tracetest-run: + build: + dockerfile: Dockerfile.tracetest + volumes: + - ./resources:/resources + environment: + TRACETEST_TOKEN: ${TRACETEST_TOKEN} + TRACETEST_ENVIRONMENT_ID: ${TRACETEST_ENVIRONMENT_ID} + entrypoint: + - bash + - /resources/run.sh + networks: + default: null + depends_on: + tracetest-apply: + condition: service_completed_successfully diff --git a/examples/quick-start-nodejs-synthetic-monitoring/resources/apply.sh b/examples/quick-start-nodejs-synthetic-monitoring/resources/apply.sh new file mode 100644 index 0000000000..4722f520ce --- /dev/null +++ b/examples/quick-start-nodejs-synthetic-monitoring/resources/apply.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +TOKEN=$TRACETEST_TOKEN +ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID + +apply() { + echo "Configuring TraceTest" + tracetest configure --token $TOKEN --environment $ENVIRONMENT_ID + + echo "Applying Resources" + tracetest apply datastore -f /resources/datastore.yaml + tracetest apply test -f /resources/test.yaml + tracetest apply monitor -f /resources/monitor.yaml +} + +apply diff --git a/examples/quick-start-nodejs-synthetic-monitoring/resources/datastore.yaml b/examples/quick-start-nodejs-synthetic-monitoring/resources/datastore.yaml new file mode 100644 index 0000000000..529adc3e53 --- /dev/null +++ b/examples/quick-start-nodejs-synthetic-monitoring/resources/datastore.yaml @@ -0,0 +1,5 @@ +type: DataStore +spec: + id: current + name: otlp + type: otlp diff --git a/examples/quick-start-nodejs-synthetic-monitoring/resources/monitor.yaml b/examples/quick-start-nodejs-synthetic-monitoring/resources/monitor.yaml new file mode 100644 index 0000000000..558cb2448c --- /dev/null +++ b/examples/quick-start-nodejs-synthetic-monitoring/resources/monitor.yaml @@ -0,0 +1,23 @@ +type: Monitor +spec: + id: JtFYYc9SR + name: Quick Start Synthetic Monitor + enabled: true + variableSetId: "" + tests: + - phAZcrT4B + schedule: + cron: "*/1 * * * *" + timeZone: Etc/UTC + alerts: + - id: slack-webhook-message + type: webhook + webhook: + body: "{\n \"text\": \"Monitor ${.Monitor.Name} has failed, follow the link to find the <${.URL}|results>\"\n}" + method: POST + url: + headers: + - key: Content-Type + value: application/json + events: + - FAILED diff --git a/examples/quick-start-nodejs-synthetic-monitoring/resources/run.sh b/examples/quick-start-nodejs-synthetic-monitoring/resources/run.sh new file mode 100644 index 0000000000..05d0f41724 --- /dev/null +++ b/examples/quick-start-nodejs-synthetic-monitoring/resources/run.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +TOKEN=$TRACETEST_TOKEN +ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID + +run() { + echo "Configuring Tracetest" + tracetest configure --token $TOKEN --environment $ENVIRONMENT_ID + + echo "Running Trace-Based Tests..." + tracetest run test -f /resources/test.yaml +} + +run diff --git a/examples/quick-start-nodejs-synthetic-monitoring/tracetest-test-api.yaml b/examples/quick-start-nodejs-synthetic-monitoring/resources/test.yaml similarity index 100% rename from examples/quick-start-nodejs-synthetic-monitoring/tracetest-test-api.yaml rename to examples/quick-start-nodejs-synthetic-monitoring/resources/test.yaml diff --git a/examples/quick-start-nodejs-synthetic-monitoring/tracetest-synthetic-monitor.yaml b/examples/quick-start-nodejs-synthetic-monitoring/tracetest-synthetic-monitor.yaml deleted file mode 100644 index a0d2ce9942..0000000000 --- a/examples/quick-start-nodejs-synthetic-monitoring/tracetest-synthetic-monitor.yaml +++ /dev/null @@ -1,23 +0,0 @@ -type: Monitor -spec: - id: SUnOrsXIg - name: Quick Start Synthetic Monitor - enabled: true - variableSetId: "" - tests: - - phAZcrT4B - schedule: - cron: "*/1 * * * *" - timeZone: Etc/UTC - alerts: - - id: slack-webhook-message - type: webhook - webhook: - body: "{\n \"text\": \"Monitor ${.Monitor.Name} has failed, follow the link to find the <${.URL}|results>\"\n}" - method: POST - url: - headers: - - key: Content-Type - value: application/json - events: - - FAILED diff --git a/examples/tracetest-synthetic-monitoring/.env.template b/examples/tracetest-synthetic-monitoring/.env.template index 0f970a2824..7e9244747b 100644 --- a/examples/tracetest-synthetic-monitoring/.env.template +++ b/examples/tracetest-synthetic-monitoring/.env.template @@ -1,2 +1,4 @@ -TRACETEST_API_TOKEN= -TRACETEST_ENVIRONMENT_ID= +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="" +TRACETEST_ENVIRONMENT_ID="" \ No newline at end of file diff --git a/examples/tracetest-synthetic-monitoring/docker-compose.yaml b/examples/tracetest-synthetic-monitoring/docker-compose.yaml index 93e4e68015..db4f5e32ee 100644 --- a/examples/tracetest-synthetic-monitoring/docker-compose.yaml +++ b/examples/tracetest-synthetic-monitoring/docker-compose.yaml @@ -7,7 +7,7 @@ services: volumes: - ./resources:/resources environment: - TRACETEST_API_KEY: ${TRACETEST_API_TOKEN} + TRACETEST_TOKEN: ${TRACETEST_TOKEN} TRACETEST_ENVIRONMENT_ID: ${TRACETEST_ENVIRONMENT_ID} entrypoint: - bash @@ -25,7 +25,7 @@ services: volumes: - ./resources:/resources environment: - TRACETEST_API_KEY: ${TRACETEST_API_TOKEN} + TRACETEST_TOKEN: ${TRACETEST_TOKEN} TRACETEST_ENVIRONMENT_ID: ${TRACETEST_ENVIRONMENT_ID} entrypoint: - bash @@ -38,7 +38,8 @@ services: tracetest-agent: environment: - TRACETEST_API_KEY: ${TRACETEST_API_TOKEN} + TRACETEST_API_KEY: ${TRACETEST_TOKEN} + TRACETEST_ENVIRONMENT_ID: ${TRACETEST_ENVIRONMENT_ID} image: kubeshop/tracetest-agent:latest networks: default: null diff --git a/examples/tracetest-synthetic-monitoring/resources/apply.sh b/examples/tracetest-synthetic-monitoring/resources/apply.sh index fb32cb77a9..75d39c41dc 100644 --- a/examples/tracetest-synthetic-monitoring/resources/apply.sh +++ b/examples/tracetest-synthetic-monitoring/resources/apply.sh @@ -2,7 +2,7 @@ set -e -TOKEN=$TRACETEST_API_KEY +TOKEN=$TRACETEST_TOKEN ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID apply() { @@ -11,7 +11,7 @@ apply() { echo "Applying Resources" tracetest apply datastore -f /resources/datastore.yaml - tracetest apply test -f /resources/import-pokemon.yaml + tracetest apply test -f /resources/test.yaml tracetest apply monitor -f /resources/monitor.yaml tracetest list monitor } diff --git a/examples/tracetest-synthetic-monitoring/resources/run.sh b/examples/tracetest-synthetic-monitoring/resources/run.sh new file mode 100644 index 0000000000..c22bdc11c6 --- /dev/null +++ b/examples/tracetest-synthetic-monitoring/resources/run.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +TOKEN=$TRACETEST_TOKEN +ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID + +run() { + echo "Configuring Tracetest" + tracetest configure --token $TOKEN --environment $ENVIRONMENT_ID + + echo "Running Trace-Based Tests..." + tracetest run test -f /resources/test.yaml + tracetest list monitor +} + +run diff --git a/examples/tracetest-synthetic-monitoring/resources/import-pokemon.yaml b/examples/tracetest-synthetic-monitoring/resources/test.yaml similarity index 100% rename from examples/tracetest-synthetic-monitoring/resources/import-pokemon.yaml rename to examples/tracetest-synthetic-monitoring/resources/test.yaml