diff --git a/astro/public/img/docs/operate/secure-and-monitor/dataDog-opentelemetry-dashboard.png b/astro/public/img/docs/operate/secure-and-monitor/dataDog-opentelemetry-dashboard.png new file mode 100644 index 0000000000..43a604fe36 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/dataDog-opentelemetry-dashboard.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-prometheus-check-summary.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-prometheus-check-summary.png new file mode 100644 index 0000000000..3285553fd5 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-prometheus-check-summary.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-prometheus-config.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-prometheus-config.png new file mode 100644 index 0000000000..0d49953ac5 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-prometheus-config.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-reporting.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-reporting.png new file mode 100644 index 0000000000..6f5ea5f8d6 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-reporting.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-windows-setup.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-windows-setup.png new file mode 100644 index 0000000000..a2dca808ed Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-agent-windows-setup.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-custom-events.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-custom-events.png new file mode 100644 index 0000000000..d89bf6d45f Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-custom-events.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-fusionauth-apikey.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-fusionauth-apikey.png new file mode 100644 index 0000000000..518e391748 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-fusionauth-apikey.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-fusionauth-enableapikey-prometheus-endpoint.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-fusionauth-enableapikey-prometheus-endpoint.png new file mode 100644 index 0000000000..9cea5bde20 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-fusionauth-enableapikey-prometheus-endpoint.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-openmetrics-dashboard.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-openmetrics-dashboard.png new file mode 100644 index 0000000000..a8cc5ec466 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-openmetrics-dashboard.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-openmetrics-install-integration.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-openmetrics-install-integration.png new file mode 100644 index 0000000000..97cfa6a63c Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-openmetrics-install-integration.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-website-create-dashboard.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-website-create-dashboard.png new file mode 100644 index 0000000000..a26ad2cab2 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-website-create-dashboard.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-website-create-new-dashboard.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-website-create-new-dashboard.png new file mode 100644 index 0000000000..1212e611c0 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-website-create-new-dashboard.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-website-metrics-explorer-prometheus.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-website-metrics-explorer-prometheus.png new file mode 100644 index 0000000000..e41109421a Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-website-metrics-explorer-prometheus.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-website-new-dashboard-configuration.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-website-new-dashboard-configuration.png new file mode 100644 index 0000000000..74f3662c72 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-website-new-dashboard-configuration.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/datadog-website-new-dashboard-preview.png b/astro/public/img/docs/operate/secure-and-monitor/datadog-website-new-dashboard-preview.png new file mode 100644 index 0000000000..0ef385d8d8 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/datadog-website-new-dashboard-preview.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/infrastructure-hosts-agent-info.png b/astro/public/img/docs/operate/secure-and-monitor/infrastructure-hosts-agent-info.png new file mode 100644 index 0000000000..4662193a3a Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/infrastructure-hosts-agent-info.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/install-datadog-agent-ubuntu.png b/astro/public/img/docs/operate/secure-and-monitor/install-datadog-agent-ubuntu.png new file mode 100644 index 0000000000..dc1db83dc1 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/install-datadog-agent-ubuntu.png differ diff --git a/astro/public/img/docs/operate/secure-and-monitor/signup-datadog-trial.png b/astro/public/img/docs/operate/secure-and-monitor/signup-datadog-trial.png new file mode 100644 index 0000000000..e83dcff863 Binary files /dev/null and b/astro/public/img/docs/operate/secure-and-monitor/signup-datadog-trial.png differ diff --git a/astro/src/content/docs/operate/secure-and-monitor/datadog.mdx b/astro/src/content/docs/operate/secure-and-monitor/datadog.mdx new file mode 100644 index 0000000000..e117ec6966 --- /dev/null +++ b/astro/src/content/docs/operate/secure-and-monitor/datadog.mdx @@ -0,0 +1,545 @@ +--- +title: Datadog Setup +description: Learn how to set up Datadog to work with FusionAuth. +navcategory: admin +section: operate +subcategory: secure and monitor + +--- +import Aside from 'src/components/Aside.astro'; +import APIBlock from 'src/components/api/APIBlock.astro'; +import APIField from 'src/components/api/APIField.astro'; +import Breadcrumb from 'src/components/Breadcrumb.astro'; +import InlineField from 'src/components/InlineField.astro'; + +## Overview + +[Datadog](https://docs.datadoghq.com/getting_started/application/) is an observability service you can integrate with your FusionAuth applications to collect events and metrics and send them to Datadog to analyze your monitoring and performance data. + +This guide, we show you how to connect FusionAuth to Datadog. It will cover: + +- How to create and set up a Datadog account +- How to add a Datadog Agent inside Fusionauth docker image to collect and export telemetry data. +- How to create a dashboard to monitor FusionAuth metrics. +- How to add a Datadog Agent on a separate (windows) host and monitor the Prometheus endpoint exposed by FusionAuth. +- How to set up an OpenTelemetry Linux collector to receive, process, and export telemetry data. +- How to add export logs or events with a Python app with the use of the Datadog API. + +## FusionAuth Metrics + +Before reading this guide, please read the [FusionAuth guide to monitoring](https://fusionauth.io/docs/operate/secure-and-monitor/monitor) to understand what metrics are available and choose the ones relevant to your needs. + +### Set Up Prometheus API Access In FusionAuth + +Fusionauth exposes metrics in a 'Prometheus Endpoint', but you must generate an API key and give permission to the "get" request to access it. +To do this + +- Log in to your FusionAuth instance and navigate to settings. Click on the API keys link. On the top-right side of the page, click on the green + to add a new API key. + +![Enable-APIKey-Prometheus-Endpoint-FusionAuth](/img/docs/operate/secure-and-monitor/datadog-fusionauth-enableapikey-prometheus-endpoint.png). + +- Enter a description for the API to identify it. Scroll down and add the GET permission on the endpoint :/api/prometheus/metrics. +- Go back to the previous screen. +- Click on the Red lock, next to the API key that you generated, to copy the value of the key. + +![APIKey-FusionAuth](/img/docs/operate/secure-and-monitor/datadog-fusionauth-apikey.png). + +## Datadog Metrics + +Please read the following documentation about metrics with Datadog to get a better understanding. + +- General introduction on metrics with Datadog(https://docs.datadoghq.com/metrics/). +- OpenTelemetry is discussed [here](https://docs.datadoghq.com/opentelemetry/?_ga=2.63663855.1324212944.1718441678-2001470719.1718441677&_gac=1.150758018.1718441678.EAIaIQobChMI1OXNip7dhgMV_UNBAh1xfQDYEAAYASAAEgIBs_D_BwE). + +## Datadog Setup + +### Sign Up For A Free Datadog Trial Account + +- Navigate to Datadog [site](https://www.datadoghq.com/). +- Click on the 'GET STARTED FREE' link and complete the registration form to get a 14-day trial. + + + +![Signup-Datadog-Trail](/img/docs/operate/secure-and-monitor/signup-datadog-trial.png) + +- After completing the account registration you will be redirected to the 'agent intstallation' page. Continue to the next section. + +### Set up The Datadog Agent + +The Datadog Agent collects metrics and events from your systems and apps. It can be installed anywhere, even on your workstation. Click on the Ubuntu agent, and it will show the below code. This will be added to the Fusionauth Dockerfile to install and start the agent. Make sure your API key and region are correct. + +```bash +DD_API_KEY= DD_SITE="us5.datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)" +``` + +![Install-Datadog-Agent-Ubuntu](/img/docs/operate/secure-and-monitor/install-datadog-agent-ubuntu.png) + + + +- Save the Dockerfile from the [FusionAuth official image](https://github.com/FusionAuth/fusionauth-containers/blob/master/docker/fusionauth/fusionauth-app/Dockerfile) to your computer. +- Edit the file. Above the paragraph labelled ###### Start FusionAuth App, you will add a version of the code generated from the Datadog site to the DockerFile. + +```bash + ### NEW FOR DATADOG ### + RUN mkdir -p /var/lib/apt/lists/partial \ + && chmod 755 /var/lib/apt/lists/partial \ + && apt update \ + && apt install -y ca-certificates curl sudo \ + && cd /usr/local/fusionauth \ + && curl -L -o install_script_agent7.sh https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh \ + && chmod +x /usr/local/fusionauth/install_script_agent7.sh + + ### Install DATADOG Agent App ### + ENV DD_API_KEY="" + ENV DD_SITE="us5.datadoghq.com" # + ENV DD_INSTALL_ONLY=false + ENV DD_HOSTNAME="fusionauthdocker" + RUN /bin/bash -c "/usr/local/fusionauth/install_script_agent7.sh" + + ### Copy the OpenMetrics configuration file ### + COPY openmetrics.d-conf.yaml /etc/datadog-agent/conf.d/openmetrics.d/conf.yaml + + # Allow fusionauth user to run datadog-agent service without password + RUN echo "fusionauth ALL=(ALL) NOPASSWD: /usr/sbin/service datadog-agent start" > /etc/sudoers.d/fusionauth + + # Ensure correct ownership and permissions for the log directory + RUN mkdir -p /usr/local/fusionauth/logs \ + && chown -R fusionauth:fusionauth /usr/local/fusionauth/logs + + # # Modify FusionAuth start script to start Datadog Agent as root and continue on failure + # RUN head -n -1 /usr/local/fusionauth/fusionauth-app/bin/start.sh > temp.sh \ + # && echo 'sudo service datadog-agent start <&- >> /dev/null' >> temp.sh \ + # && mv temp.sh /usr/local/fusionauth/fusionauth-app/bin/start.sh \ + # && chown fusionauth:fusionauth /usr/local/fusionauth/fusionauth-app/bin/start.sh \ + # && chmod +x /usr/local/fusionauth/fusionauth-app/bin/start.sh + +``` + +- Download the Datadog agent from https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh, and set some extra environment variables to complete the installation. +- After installing the Datadog agent, copy the config(openmetrics.d-conf.yaml), to handle the open metrics integration. + +openmetrics.d-conf.yaml: + + ```yaml + init_config: + instances: + - prometheus_url: http://localhost:9011/api/prometheus/metrics + namespace: Fusionauth_docker_metrics_openmetric_agent + metrics: + - '*' + headers: + Authorization: '' + Content-Type: 'application/json' +``` + +Build the Dockerfile into a new image to use in place of the official FusionAuth one. + +```sh +docker build --platform linux/amd64 -t faimage . +``` + +Use the docker-compose-yaml file from the FusionAuth [five-minute guide](/docs/quickstarts/5-minute-setup-guide). + +To start the docker containers use docker-compose + +``` bash + docker-compose.exe -f .\docker-compose.yml up -d + +``` + + + ```bash + docker ps # to get the uid for the FAimage i.e 0d + + docker exec -u root -it 0d service datadog-agent start #start the agent + + docker exec -u root -it 0d service datadog-agent status #get tehe service status shoud respomnd with * datadog-agent is running + ``` + +When the agent is successfully installed and started, you will get a screen that will refresh and indicate that reports from the agent are received. Click on finish to continue. + + + +![Infrastructure-Hosts-Agent](/img/docs/operate/secure-and-monitor/infrastructure-hosts-agent-info.png) + +### Create Your First Dashboard + +![Datadog-Agent-Reporting](/img/docs/operate/secure-and-monitor/datadog-agent-reporting.png) + +- On the Create Dashboard, click on the Create Dashboard. + +![Datadog-Agent-Reporting](/img/docs/operate/secure-and-monitor/datadog-website-create-dashboard.png) + +- Name the dashboard. If you have organizations configured, you may select the team or ignore it of not. You can select your preferred layout. Click on 'New Dashboard'. + +![Datadog-Agent-Reporting](/img/docs/operate/secure-and-monitor/datadog-website-create-new-dashboard.png) + + + +Add data to the dashboard. + +- For visualization, choose TimeSeries. +- Add the following to Metrics to monitor: system.net.bytes_rcvd, system.net.bytes_sen. On the right side, change the colour to yellow in the one metric to see the difference. +- For the time preference choose last 15 minutes. +- Give a title to the graph. Click on save. + +![Datadog-Website-New-Dashboard-Configuration](/img/docs/operate/secure-and-monitor/datadog-website-new-dashboard-configuration.png) + +You created your first dashboard page!. +![Datadog-Website-New-Dashboard-Configuration](/img/docs/operate/secure-and-monitor/datadog-website-new-dashboard-preview.png) + +## Add OpenMetrics Integration In Datadog. + +Fusionauth exposes a Prometheus endpoint, which can be monitored by an "openMetric" Integration in Datadog. + +- On the Main Datadog website, Click the Integrations tab in the bottom left. Search for open metrics, and click on the tile presented. + +![Datadog-Website-Integrations-OpenMetrics](/img/docs/operate/secure-and-monitor/datadog-openmetrics-install-integration.png) + +The installation consists of 2 parts. + +- Click on the installation-button, in the top right. +- Configured the OpenMertics Section in the agent. + + + +Use the sample config file to configure the open metrics integrations. It was already copied to the docker container when we created it. + +``` yaml +init_config: +instances: + - prometheus_url: http://localhost:9011/api/prometheus/metrics + namespace: Fusionauth_docker_metrics_openmetric_agent #any name that you want reflected in datadog + metrics: + - '*' + headers: + Authorization: '' + Content-Type: 'application/json' +``` + +This file must be copied to the config folder after the installation of the Datadog agent to send metrics to Datadog. This must be added to the DockerFile before the section ### start the agent ### + +``` bash + # Copy the OpenMetrics configuration file + COPY openmedtrics.d-conf.yaml /etc/datadog-agent/conf.d/openmetrics.d/conf.yaml +``` + +When successfully configured, the Datadog container and the Datadog agent should start sending data to Datadog. + +Below is a sample of the data sent. + +![Datadog Openmetrics Dashboard](/img/docs/operate/secure-and-monitor/datadog-openmetrics-dashboard.png) + +You can add a new dashboard time display these metrics, using the same steps as [Create Your First Dashboard](#create-your-first-dashboard). +Use your namespace from the config file i.e. Fusionauth_docker_metrics_openmetric_agent to search for metrics to add from this agent. + +### Add The Datadog Agent On A Remote Host To Capture Prometheus/Open Metric Data + +The Datadog agent can be installed on a separate machine to monitor Prometheus metrics from a remote fusionauth host. You can install the Windows datadog agent on a Windows host and monitor a remote FusionAuth Host. +Before Installing and configuring the Prometheus agent, install the Prometheus integrations using similar steps as used in [Add OpenMetrics Integration in Datadog](#add-openmetrics-integration-in-datadog), +but instead of searching for Openmetrics, search for [Prometheus](https://us5.datadoghq.com/integrations/prometheus?search=Prometheus). + +Navigate to the agent download [page](https://us5.datadoghq.com/account/settings/agent/latest?platform=overview). + +- Click on Windows. If you have more than one API key, you can select the one to use. We only have one and will use that one. +- Make sure of the region. The guide use "us5.datadoghq.com", but yours might vary depending on the selection when you created your Datadog [account](#sign-up-for-a-free-datadog-trial-account). +- Click Download Agent Installer. If asked, Choose a folder to save the download, else it will be saved in your default downloads folder. +- Run the installer (as Administrator) by opening datadog-agent-7-latest.amd64.msi. +- Follow the prompts, accept the license agreement, and enter your Datadog API key, enter your Datadog Region: us5.datadoghq.com +- When the installation finishes, you are given the option to launch the Datadog Agent Manager. Launch the Datadog agent Manager + +![Datadog-Agent-Windows-Setup](/img/docs/operate/secure-and-monitor/datadog-agent-windows-setup.png) + +- Look for a green button at the top that says "Connected to agent". If not, follow the installation instructions again. +- Click on checks on the menu and select manage checks. Select Prometheus from the list. + +![Datadog-Agent-Prometheus-Config](/img/docs/operate/secure-and-monitor/datadog-agent-prometheus-config.png) + +Complete the following config for the remote Fusionauth server, in the right-hand pane: + +```yaml +## All options defined here are available to all instances. +init_config: + +instances: +- prometheus_url: https:///api/prometheus/metrics + namespace: Prometheus_remote_metrics #namespace to identify requests in datadog + metrics: + - '*' #you can filter or add specific metrics here , see documentation. + headers: + Authorization: 'Prometheus_remote_metrics and add metrics in the metric explorer. Choose the last 15 minutes for the period. You will see that data being pulled from the Prometheus fusionauth endpoint.- Following the steps above when we created a [dashboard](#create-your-first-dashboard), you can easily add these metrics to the dashboards required. + +![Datadog-Website-Metrics-Exploere-Prometheus](/img/docs/operate/secure-and-monitor/datadog-website-metrics-explorer-prometheus.png) + +## Send Events With A Python App To Datadog + +Datadog also provides an API whereby you can create cron jobs or services that run on your FusionAuth that provide additional/ custom events or logs to Datadog. + +Below is a sample python appliaciont that just checks if a given FusionAuth host is alive/not alive and sent the status event to Datadog. + +Run the following command before you try the script: + +```bash + pip install requests datadog-api-client +``` + +```python +import requests + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.events_api import EventsApi +from datadog_api_client.v1.model.event_create_request import EventCreateRequest +from datetime import datetime + +# Get the current date and time +now = datetime.now() + + +def is_website_alive(url): + try: + response = requests.get(url, timeout=10) + # Check if the response status code is 200 (OK) + if response.status_code == 200: + return True + else: + return False + except requests.RequestException as e: + # If there was an issue (e.g., network error, timeout), the website is not reachable + print(f"Error: {e}") + return False + + +formatted_now = now.strftime("%Y-%m-%d %H:%M:%S") + + +url = "https://" +if is_website_alive(url): + status = f"[{ formatted_now}] - {url} is alive. " +else: + status = f"[{ formatted_now}] - {url} is not reachable." + +#### here you can define your message/event +body = EventCreateRequest( + title="FusionAuthStatusEvent", + text=status, + tags=[ + "FusionAuth:StatusEvent", + ], +) + + + +configuration = Configuration() + +configuration.api_key["apiKeyAuth"] = "" +configuration.server_variables["site"] = "us5.datadoghq.com" #your Region +configuration.api_key["appKeyAuth"] = "" + +with ApiClient(configuration) as api_client: + api_instance = EventsApi(api_client) + response = api_instance.create_event(body=body) + + print(response) +``` + +When you navigate [to](https://us5.datadoghq.com/event/overview) and click on Explorer, you will see the event that was logged with the script. + +![DataDog-Custom-Events](/img/docs/operate/secure-and-monitor/datadog-custom-events.png) +Read more about all the possible API's [here](https://docs.datadoghq.com/api/latest/using-the-api/). + +## Send Data To Datadog With The Opentelemetry Colector + +You can also use the open telemetry java colletor to push data from the Fusionauth host to Datadog. + +You must modify the official FusionAuth Docker image to download the OpenTelemetry Java agent and change the script that starts FusionAuth. +Configuration values for Java OpenTelemetry are described [here](https://opentelemetry.io/docs/languages/java/configuration). + +Save the Dockerfile from the [FusionAuth official image](https://github.com/FusionAuth/fusionauth-containers/blob/master/docker/fusionauth/fusionauth-app/Dockerfile) to your computer. + +Edit the file. Above the paragraph labelled ###### Start FusionAuth App, insert the code below. + +```bash +##### NEW FOR OPENTELEMETRY ####################################################################### +RUN mkdir -p /var/lib/apt/lists/partial \ + && chmod 755 /var/lib/apt/lists/partial \ + && apt update \ + && apt install -y ca-certificates \ + && cd /usr/local/fusionauth \ + && curl -L -o otel.jar https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.4.0/opentelemetry-javaagent.jar\ + && (head -n -1 /usr/local/fusionauth/fusionauth-app/bin/start.sh; echo 'exec "${JAVA_HOME}/bin/java" -javaagent:/usr/local/fusionauth/otel.jar -Dotel.resource.attributes=service.name=fusionauth -Dotel.traces.exporter=otlp -Dotel.exporter.otlp.endpoint=http://otel:4318 -cp "${CLASSPATH}" ${JAVA_OPTS} io.fusionauth.app.FusionAuthMain <&- >> "${LOG_DIR}/fusionauth-app.log" 2>&1') > temp.sh \ + && mv temp.sh /usr/local/fusionauth/fusionauth-app/bin/start.sh; +RUN chown fusionauth:fusionauth /usr/local/fusionauth/otel.jar /usr/local/fusionauth/fusionauth-app/bin/start.sh \ + && chmod +x /usr/local/fusionauth/fusionauth-app/bin/start.sh +``` + +- This code edits start.sh, which is the command run when the container starts, to start FusionAuth using OpenTelemetry. +- The command takes the head of the file (all lines except the last), and writes the new command to the end of the file. + +By default, the OpenTelemetry Java agent sends data to the OpenTelemetry collector at http://localhost:4317. It was changed to send data to the container, at http://otel:4318. + +Build the Dockerfile into a new image to use in place of the official FusionAuth one. + +```sh +docker build --platform linux/amd64 -t faimage . +``` + +Modify the docker-compose-yaml file from the FusionAuth [five-minute guide](/docs/quickstarts/5-minute-setup-guide) to have the content below. +The Opentelemetery collector is now included in your compose file. + +``` yaml +# OpenTelemetry Collector Contrib + otel: + image: otel/opentelemetry-collector-contrib:latest + volumes: + - ./otel-collector.yml:/etc/otel-collector.yml + command: ["--config=/etc/otel-collector.yml"] + #,"--feature-gates=-exporter.datadogexporter.DisableAPMStats"] + ports: + - "1888:1888" # pprof extension + - "8888:8888" # Prometheus metrics exposed by the collector + - "8889:8889" # Prometheus exporter metrics + - "13133:13133" # health_check extension + - "4317:4317" # OTLP gRPC receiver + - "4318:4318" # OTLP gRPC receiver + - "55679:55679" # zpages extension + environment: + - OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://otel:4318/v1/logs + - OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://otel:4318 + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel:4318/v1/traces + networks: + - db_net + + depends_on: + - db + - search + - fusionauth + +``` + +You must also configure the otel-collector.yml file for use with this container. This file is passed into the container through the docker-compose yaml. + +```yaml +receivers: + hostmetrics: + scrapers: + load: + cpu: + disk: + filesystem: + memory: + network: + paging: + # process: + otlp: + protocols: + http: + #endpoint: "localhost:4318" + grpc: + #endpoint: "localhost:4317" +processors: + batch: + send_batch_max_size: 100 + send_batch_size: 10 + timeout: 10s + +connectors: + datadog/connector: + +exporters: + datadog/exporter: + api: + site: "us5.datadoghq.com" # + key: "" +service: + pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [datadog/connector, datadog/exporter] + metrics: + receivers: [hostmetrics, otlp, datadog/connector] #// The connector provides the metrics to your metrics pipeline + processors: [batch] + exporters: [datadog/exporter] + +``` + +Start the docker-compose with + +```bash + docker-compose -f ./docker-compose.yaml up -d + +#if you want to monitor the progress +# docker-compose logs --follow +``` + +### Visualize The Opentelemetery Metrics In Datadog + + +- Navigate to dashboards. Click on dashboard list. Click on OpenTelemetry Host Metrics Dashboard +- If you followed the guide correctly you will see some metrics on the graps +[DataDog-opentelemetry-Dashboard](/img/docs/operate/secure-and-monitor/dataDog-opentelemetry-dashboard.png) + +## Conclusion + +The guide looked at various ways to get data into Datadog from a FusionAuth instance. + +- The Datadog agent could be installed and configured with various integrations inside the FusionAuth docker container. +- The OpenTelemetry collector can be installed inside the docker container to collect data with the Linux collector. +- The Datadog agent can be installed on an external host to monitorFusionAuth Prometheus Endpoint. +- You looked at using the API in a Python app to push sample events/logs to Datadog. + + You can visualize collected metrics in dashboards created on the Datadog website. It is fair to say many metrics are available from fusionauth to Datadog. Should you need any others, you can create your own using the API. + +## Further Reading + +- FusionAuth metrics — https://fusionauth.io/docs/operate/secure-and-monitor/monitor#metrics. +- OpenTelemetry documentation — https://opentelemetry.io/docs/what-is-opentelemetry. +- OpenTelemetry Java documentation — https://github.com/open-telemetry/opentelemetry-java-instrumentation +- Datadog OpenTelemetry documentation — https://docs.datadoghq.com/opentelemetry/collector_exporter/ +- Fusionauth containers — https://github.com/FusionAuth/fusionauth-containers/blob/master/docker/fusionauth/fusionauth-app/Dockerfile +- Getting Started with the Datadog Agent - https://docs.datadoghq.com/getting_started/agent/ +- Datadog Ubuntu Agent Install Script Configurations options - https://github.com/DataDog/agent-linux-install-script/blob/main/README.md#agent-configuration-options +- FusionAuth Docker Install For the 5-Minute Guide - https://fusionauth.io/docs/quickstarts/5-minute-docker +- Pricing - https://www.datadoghq.com/pricing/ +- Datadog Metrics - https://docs.datadoghq.com/metrics/ +- Datadog Agents - https://docs.datadoghq.com/getting_started/agent/