Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the monitoring library.
LangChain
from langchain.monitoring import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Prometheus' which is a monitoring system but not imported directly here.
Using 'AlertManager' which is for alerts but not the main monitor class.
✗ Incorrect
The Monitor class is used to set up monitoring in LangChain.
2fill in blank
mediumComplete the code to create a monitor instance for your LangChain app.
LangChain
monitor = [1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to instantiate 'Logger' which is for logging, not monitoring.
Using 'Prometheus' which is not a class here.
✗ Incorrect
You create a monitor instance by calling the Monitor class.
3fill in blank
hardFix the error in the alert setup code by completing the missing alert type.
LangChain
monitor.setup_alert(alert_type='[1]', threshold=5)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'email' without configuring email server.
Using 'sms' which requires phone integration.
✗ Incorrect
The webhook alert type allows sending alerts to external services via HTTP requests.
4fill in blank
hardFill both blanks to create a metric and register it with the monitor.
LangChain
metric = [1]('request_count', description='Count of requests') monitor.[2](metric)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Gauge which measures values that can go up and down.
Using 'register_metric' which is not the correct method name.
✗ Incorrect
A Counter tracks counts like requests, and add_metric registers it with the monitor.
5fill in blank
hardFill all three blanks to create an alert rule for high latency.
LangChain
alert_rule = {
'[1]': 'latency',
'condition': lambda x: x [2] 1000,
'action': '[3]'
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'threshold' as a key instead of 'metric'.
Using '<' instead of '>' in the condition.
✗ Incorrect
The alert rule uses 'metric' to specify what to watch, '>' to check if latency is over 1000ms, and 'send_alert' as the action.