# Integrate APM provider How to set up Platform Insights for your APM service provider. [Platform Insights](https://docs.commercetools.com/api/platform-insights.md) lets you forward commercetools API telemetry to your Application Performance Monitoring (APM) provider. You can send two types of data by setting the `eventTypes` field in your configuration: - Metrics: aggregated request data, including attributes such as `endpoint`, `http_method`, and `http_status`. Use this to monitor API performance and usage patterns. - Logs: individual request log entries. Use this for detailed tracing and debugging. You can enable one or both event types per provider, and configure up to five providers simultaneously. For example, you can send metrics to New Relic and Datadog at the same time by including both in the `providers` array of a single request. ## Prerequisites Before you begin, make sure you have the following: - A commercetools Project with an API Client that has the `manage_project_settings:{projectKey}` scope. Replace the `{region}` placeholder in the request URLs with the value for your Project's Region. For the available values, see [Hosts](https://docs.commercetools.com/api/general-concepts.md#hosts). - A Bearer Token for your API Client. For guidance on obtaining one, see [Client credentials flow](https://docs.commercetools.com/api/authorization.md#client-credentials-flow). - The [Platform Insights](https://docs.commercetools.com/api/platform-insights.md) add-on activated for your commercetools Project. - An active account with your chosen APM provider. ## New Relic Log in to your New Relic account. Navigate to the Account Settings page and select API Keys. Create a new API key of type Ingest - License. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/newrelic-apikey.png Alt text: New Relic Ingest License key creation With this API key, you can configure Platform Insights to send data to New Relic. Send a PUT request to the following endpoint with the API key and region in the body. The supported values for `region` are `eu` and `us`: ```bash title="Configure Platform Insights for New Relic" curl -X PUT https://api.{region}.commercetools.com/{projectKey}/insights-configuration -i --header "Authorization: Bearer ${BEARER_TOKEN}" --header 'Content-Type: application/json' --data-binary @- << DATA { "providers" : [ { "type" : "NewRelic", "region" : "eu", "apiKey" : "eu12345NRAL", "eventTypes" : [ "Metrics", "Logs" ] } ] } DATA ``` After a successful response, it may take up to five minutes for the data to start flowing to New Relic. ### View the commercetools service After Platform Insights sends data, a new service called commercetools appears under APM & Services. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/newrelic-service-section.png Alt text: New Relic service section All data from commercetools through Platform Insights appears under the commercetools service. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/newrelic-service-overview\.png Alt text: New Relic service overview ### Metrics To analyze the data further, use the Query Console. All metrics from commercetools are prefixed with `ct_`, and you can filter them in the data explorer. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/newrelic-query-console.png Alt text: New Relic query console All metrics provide attributes like `endpoint`, `http_method`, and `http_status` to help you understand the performance of your API usage. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/newrelic-query-console-attributes.png Alt text: New Relic query console with metric attributes ### Logs Besides the aggregated metrics, you can also see the logs from commercetools. To receive them in addition to metrics, include `Logs` in the `eventTypes` array of your configuration request. They appear in the Logs section of the commercetools service. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/newrelic-logs.png Alt text: New Relic logs Image url: https://docs.commercetools.com/tutorials/images/platform-insights/newrelic-log-entry.png Alt text: New Relic log entry For more information, see the [New Relic documentation](https://docs.newrelic.com/docs/new-relic-solutions/get-started/intro-new-relic/). ## Datadog Log in to your Datadog account. Navigate to Organization Settings and select API Keys. Create a new API key and copy its value. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/datadog-apikey.png Alt text: Datadog API key creation With this API key, you can configure Platform Insights to send data to Datadog. Send a PUT request to the following endpoint with the API key and site in the body: ```bash title="Configure Platform Insights for Datadog" curl -X PUT https://api.{region}.commercetools.com/{projectKey}/insights-configuration -i --header "Authorization: Bearer ${BEARER_TOKEN}" --header 'Content-Type: application/json' --data-binary @- << DATA { "providers" : [ { "type" : "Datadog", "site" : "EU1", "apiKey" : "ddApiKey12345", "eventTypes" : [ "Metrics", "Logs" ] } ] } DATA ``` Set `site` to the value that matches your Datadog organization. The following values are supported: `US1`, `US3`, `US5`, `EU1`, `US1-FED`, and `AP1`. After a successful response, it may take up to five minutes for the data to start flowing to Datadog. ### Metrics All metrics sent from commercetools are prefixed with `ct_` and include attributes such as `endpoint`, `http_method`, and `http_status`. You can explore them using the Metrics Explorer in your Datadog account. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/datadog-metrics-explorer.png Alt text: Datadog metrics explorer ### Logs To receive logs in addition to metrics, include `Logs` in the `eventTypes` array of your configuration request. You can view the incoming logs in the Log Explorer section of your Datadog account. Use the search and filtering tools to explore your commercetools API activity. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/datadog-log-explorer.png Alt text: Datadog log explorer Image url: https://docs.commercetools.com/tutorials/images/platform-insights/datadog-log-entry.png Alt text: Datadog log entry For more information, see the [Datadog documentation](https://docs.datadoghq.com/). ## Dynatrace Log in to your Dynatrace account. Navigate to Access Tokens and create a new token with the `Ingest-Logs` and `Ingest-Metrics` scopes. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/dynatrace-apikey.png Alt text: Dynatrace access token creation You also need your environment ID, which is the subdomain of your Dynatrace URL. For example, if your Dynatrace URL is `https://dtMyEnvironment.live.dynatrace.com`, your environment ID is `dtMyEnvironment`. With the token and environment ID, send a PUT request to configure Platform Insights: ```bash title="Configure Platform Insights for Dynatrace" curl -X PUT https://api.{region}.commercetools.com/{projectKey}/insights-configuration -i --header "Authorization: Bearer ${BEARER_TOKEN}" --header 'Content-Type: application/json' --data-binary @- << DATA { "providers" : [ { "type" : "DynatraceSaaS", "environmentId" : "dtMyEnvironment", "apiKey" : "dtabc1234", "eventTypes" : [ "Metrics", "Logs" ] } ] } DATA ``` After a successful response, it may take up to five minutes for the data to start flowing to Dynatrace. ### Metrics All metrics sent from commercetools are prefixed with `ct_` and include attributes such as `endpoint`, `http_method`, and `http_status`. You can create a new dashboard to visualize them in a panel. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/dynatrace-metrics.png Alt text: Dynatrace metrics dashboard Image url: https://docs.commercetools.com/tutorials/images/platform-insights/dynatrace-metrics-explorer.png Alt text: Dynatrace metrics explorer ### Logs To receive logs in addition to metrics, include `Logs` in the `eventTypes` array of your configuration request. After configuration, Platform Insights sends request logs from commercetools directly to Dynatrace. You can view the incoming logs in the Logs section of your Dynatrace account. Image url: https://docs.commercetools.com/tutorials/images/platform-insights/dynatrace-logs.png Alt text: Dynatrace logs For more information, see the [Dynatrace documentation](https://docs.dynatrace.com/). ## Verify your configuration To confirm that your configuration was saved correctly, send a GET request to the same endpoint: ```bash title="Retrieve Platform Insights configuration" curl -X GET https://api.{region}.commercetools.com/{projectKey}/insights-configuration --header "Authorization: Bearer ${BEARER_TOKEN}" ``` The response contains a `ProjectConfiguration` object with your active providers, their event types, and the time the configuration was last modified. ## Related pages - [Section overview page](https://docs.commercetools.com/tutorials.md) - [Previous page: Integrate CPQ](https://docs.commercetools.com/tutorials/cpq-integration.md)