Skip to content

monitoring with ngrok and datadog #1272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 56 commits into from

Conversation

sixhobbits
Copy link

@sixhobbits sixhobbits commented Apr 4, 2025

For @joelhans

  • WIP draft showing how to monitor and integrate with datadog
  • Still running through QA on our end
  • Might need to be adapted for a more complicated example
  • Also some open questions about open telemetery etc

Copy link

vercel bot commented Apr 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
ngrok-docs ✅ Ready (Inspect) Visit Preview May 7, 2025 4:45pm

Copy link
Contributor

@joelhans joelhans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving some feedback here to start with! I wanted to start with some overall change in direction, mostly based on a few questions I had and to make this read as an actual follow-on to the API gateway guides we already have.

I really love the What to monitor? section! And as a whole, this fills a huge gap in our docs/how-tos in how to actually use all the observability tools in ngrok.

Some other things:

  1. We should move this from /docs/guides/other-guides/ to /docs/guides/api-gateway/ to make the movement from API gateway guides into this more "official."
  2. I need to go through this with more detail in another pass, but overall the prose feels good.
  3. I'm going back and forth on whether we should keep the steps as bulleted lists. It works well with highly specific processes that a user needs to follow, like setting up Datadog, but doesn't align perfectly with some of our recent guides.
  4. We need to remove the changes to pnpm.lock to merge this.


This guide explains how to monitor your API or web app with ngrok by viewing traffic reports, using error request replays, and exporting logs and events to an external dashboard.

Whether you're an existing ngrok user looking to make your API more robust or a new user wondering whether ngrok meets your needs, this tutorial will demonstrate monitoring in detail.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary—we can cut.

Comment on lines 20 to 53
## Start the sample API to monitor

Let's start the sample API. Open a terminal and run the commands below.

```sh
docker network create ngrokTest

docker run --init --platform=linux/amd64 --rm -p 4000:80 --network=ngrokTest --name="api" -e PORT=80 joelatngrok/api-demo
```

This command runs the Docker sample API container, exposing the API locally on port 4000, names the Docker container `api`, and removes the container with `--rm` upon exiting. You can now browse to http://localhost:4000 to test the API.

:::note
The API uses a named network, `ngrokTest`, so that in the next section, you can start the ngrok Agent on the same network as the API.
:::

![Simple web API](./img/simple-web-api.png)

## Publish your API with ngrok

Now that the API is running locally, you can expose it on a public URL, using the [Docker image for the ngrok agent](https://hub.docker.com/r/ngrok/ngrok).

- Replace the authentication token in the command below with your token from the [ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken), and run the command in a new terminal.

```sh
docker run -it --rm --platform=linux/amd64 --network=ngrokTest -e NGROK_AUTHTOKEN=Y0urS3cr3tK3y ngrok/ngrok:3.22.0-alpine-amd64 http http://api
```

This command starts the ngrok agent locally and connects it to the API running on the `api` container.

- Browse to the URL labeled `Forwarding`, which should look like this in your terminal: `https://eb45-79-127-145-72.ngrok-free.app`.
- You can now see your request going from the browser to the ngrok agent you're running in one terminal window and then to the API in your other terminal window.

![Published API](./img/api-gent.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'd prefer to do here is cut all this and instead use the change I requested above, which points folks to the previous API gateway guides, so that they already have the API demo app running and their whole API gateway configured.

- The [ngrok Agent Endpoints](https://ngrok.com/docs/universal-gateway/agent-endpoints) documentation
- The [ngrok Events](https://ngrok.com/docs/obs/events) documentation
- [Datadog](https://www.datadoghq.com)
- [ntfy](https://ntfy.sh)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this link is here.

@@ -48,6 +48,12 @@ Once Full Capture is enabled, a replay button will appear for fully captured req

Replay works by resending your original unmodified request to your endpoint. It will be subject to the policies of that endpoint at the time of replay (which could be different than the original request).

:::warning

You need to use a permanent endpoint for your service for replay to work. If you are using a free ngrok account, where the URL changes every time you restart the agent, the replay request will fail as it tries to contact an endpoint that no longer exists.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this only true if you've stopped or restarted your agent since the request was logged in Traffic Inspector?


- Sign up for a [Datadog](https://www.datadoghq.com) trial account. (You will eventually need a paid Datadog plan to continue using logs and monitors.)

You can enter anonymous dummy values instead of your personal information for all the Datadog registration fields except your email address, which you need to confirm. You also can't skip the third step of the sign-up process, in which you create a Datadog agent somewhere.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this tip of using dummy values—feels incongruous with our target ICP here, who are more DevOps/infra engineers with production API gateways.

Comment on lines 164 to 175
- In Step 3 of the Datadog sign-up, click on **Docker** in the sidebar. Copy and paste the given command into a terminal and run it.

![Join Datadog](./img/joinDatadog.png)

- Once the Datadog site notices your agent is running, click **Finish** at the bottom of the page.
- You now no longer need the agent running locally and can remove the Datadog container with the command below.

```sh
docker stop dd-agent
docker remove dd-agent
docker image rm gcr.io/datadoghq/agent:7
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joelhans joelhans marked this pull request as ready for review May 6, 2025 18:37
@joelhans
Copy link
Contributor

joelhans commented May 6, 2025

Also flipping this over to ready to be reviewed to we can get CI running on it and look at deploy previews.

rideam and others added 7 commits May 7, 2025 14:20
# Conflicts:
#	docs/guides/api-gateway/get-started.mdx
#	docs/guides/api-gateway/kubernetes.mdx
#	docs/guides/api-gateway/multicloud.mdx
feedback updates Monitoring ngrok
Copy link
Contributor

autofix-ci bot commented May 13, 2025

Hi! I'm autofix logoautofix.ci, a bot that automatically fixes trivial issues such as code formatting in pull requests.

I would like to apply some automated changes to this pull request, but it looks like I don't have the necessary permissions to do so. To get this pull request into a mergeable state, please do one of the following two things:

  1. Allow edits by maintainers for your pull request, and then re-trigger CI (for example by pushing a new commit).
  2. Manually fix the issues identified for your pull request (see the GitHub Actions output for details on what I would like to change).

@joelhans
Copy link
Contributor

@joelhans
Copy link
Contributor

Closing in favor if #1351—thank you @sixhobbits and team for carrying it this far!

@joelhans joelhans closed this May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants