Prerequisites
- Ensure you have access to a Google Dialogflow account and have a Dialogflow agent set up.
- Have an active New Relic account with the ability to create applications and monitor them.
- Basic understanding of cloud services, APIs, and logging.
Set Up Dialogflow
- Log into the Google Cloud Console and navigate to the Dialogflow ES console.
- Select or create a Dialogflow agent.
- Go to the 'Integrations' menu and ensure that API is enabled.
Create a Basic Dialogflow Agent
- Define intents and entities that will trigger the actions you want to monitor.
- Test the intents in Dialogflow and make sure they function as expected.
Enable Event Forwarding
- Access the Google Cloud Console.
- Navigate to the Pub/Sub section and create a Pub/Sub topic that Dialogflow will use to forward events.
- In the Dialogflow console, go to the Fulfillment page and enable 'Webhook' and 'Pub/Sub' for integrations.
- Provide the topic name from Pub/Sub as the means of forwarding messages.
Install New Relic Agent
- Access your New Relic account, and go to the installation instructions for the programming language you are using (Node.js, Python, etc.).
- Usually, the installation involves adding New Relic's agent to your application, for example:
npm install newrelic --save
- Configure the New Relic agent by creating the
newrelic.js
or equivalent configuration file and adding your New Relic license key.
Subscribe to the Pub/Sub Topic
- Create a new service to handle messages from the Pub/Sub topic. This service will process messages and then send relevant information to New Relic.
- You might use a framework or cloud function to set up this service, depending on your preference and environment:
import os
from google.cloud import pubsub_v1
from newrelic_telemetry_sdk import Log
def callback(message):
log_msg = Log(message.data)
newrelic_client.send(log_msg)
message.ack()
subscriber = pubsub_v1.SubscriberClient()
subscription_path = 'projects/{project_id}/subscriptions/{sub_id}'
subscriber.subscribe(subscription_path, callback=callback)
Monitor Using New Relic
- Go to your New Relic account and navigate to the new logs or applications you created.
- Monitor the metrics and logs that are being generated from your Dialogflow agent to ensure integration is working successfully.
- Customize and set alerts, dashboards as per your requirements to get insights.
Test and Validate
- Trigger various intents within your Dialogflow agent to test if the events are correctly being logged in New Relic.
- Check both Dialogflow and New Relic dashboards for data consistency.
Optimize and Enhance
- Use New Relic's insights to identify any unnecessary intents or excessive usage that might need streamlining.
- Consider setting up additional alerts for potential issues.