Enhance Your Data Queries with Honeycomb's Natural Language Processing Actions

In the world of data analytics, transforming complex datasets into understandable insights is essential. The hamelsmu/honeycomb API provides powerful Cognitive Actions that leverage advanced Natural Language Processing (NLP) capabilities. Among these actions, the ability to generate Natural Language Queries (NLQs) for Honeycomb data is a game changer, allowing developers to interact with their data in a more human-friendly manner. This article will guide you through the Generate Honeycomb NLQ action, detailing its purpose, inputs, outputs, and how you can integrate it into your applications.
Prerequisites
Before diving into the Cognitive Actions, ensure you have the following:
- An API key for accessing the Cognitive Actions platform.
- Familiarity with making HTTP requests and handling JSON data.
- Basic knowledge of Python for the conceptual code examples provided.
Authentication typically involves passing your API key in the headers of your requests.
Cognitive Actions Overview
Generate Honeycomb NLQ
The Generate Honeycomb NLQ action allows you to create a Natural Language Query for Honeycomb data using the Mistral QLoRA v6 model. This action is designed to enhance prediction accuracy and efficiency by converting human-readable queries into structured requests that the Honeycomb API can process.
- Category: NLP
Input
The input for this action requires the following fields:
- columns: A string representation of the list of column names to include in the response. This field is required.
- naturalLanguageQuery: The natural language query string to be processed. This field is also required.
- maxNewTokens (optional): The maximum number of tokens the model should generate as output. Defaults to 5000.
Example Input:
{
"columns": "['net.transport', 'nodejs_eventloop_lag_p99_seconds', 'nodejs_eventloop_lag_p90_seconds', 'nodejs_version_info', 'http.url', 'nodejs_eventloop_lag_seconds', 'laneId', 'nodejs_eventloop_lag_p50_seconds', 'organization.id', 'workspace.id', 'service.name', 'nodejs_eventloop_lag_min_seconds', 'nodejs_eventloop_lag_max_seconds', 'peer.ipv4', 'nodejs_active_requests', 'nodejs_active_requests_total', 'nodejs_eventloop_lag_mean_seconds', 'err', 'nodejs_active_resources', 'telemetry.sdk.name', 'net.host.port', 'http.host', 'cloud.region', 'cloud.platform', 'nodejs_external_memory_bytes', 'link', 'net.host.name', 'api.endpoint', 'error', 'net.host.ip', 'span_id', 'nodejs_heap_space_size_available_bytes', 'net.peer.name', 'aws.region', 'cloud.account.id', 'net.peer.port', 'aws.ecs.cluster.arn', 'service.instance.id', 'searchResponse', 'nodejs_active_resources_total', 'workspaceId', 'nodejs_heap_space_size_total_bytes', 'span.kind', 'space', 'telemetry.instrumentation_library', 'net.peer.ip', 'container.cpu.onlines', 'cloud.availability_zone', 'telemetry.sdk.version', 'nodejs_active_handles', 'duration_ms', 'http.status_code', 'db.statement', 'http.route', 'parent_name', 'exception.message', 'name', 'trace.parent_id']",
"maxNewTokens": 5000,
"naturalLanguageQuery": "EMISSING endpoint analytics.service.com"
}
Output
This action typically returns a structured output that includes:
- orders: Instructions on how to sort the results.
- filters: Conditions applied to the query results.
- breakdowns: Fields used to segment the results.
- time_range: The time span for the data being queried.
- calculations: Operations to be performed on the data.
Example Output:
{
"orders": [
{
"op": "COUNT",
"order": "descending"
}
],
"filters": [
{
"op": "=",
"value": "analytics.service.com",
"column": "api.endpoint",
"join_column": ""
},
{
"op": "=",
"value": true,
"column": "err",
"join_column": ""
}
],
"breakdowns": [
"api.endpoint"
],
"time_range": 7200,
"calculations": [
{
"op": "COUNT"
}
]
}
Conceptual Usage Example (Python)
Here’s how you might call the Generate Honeycomb NLQ action in Python:
import requests
import json
# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint
action_id = "2f664938-c74b-4d18-936f-8eae771d509a" # Action ID for Generate Honeycomb NLQ
# Construct the input payload based on the action's requirements
payload = {
"columns": "['net.transport', 'nodejs_eventloop_lag_p99_seconds', 'nodejs_eventloop_lag_p90_seconds', 'nodejs_version_info', 'http.url', 'nodejs_eventloop_lag_seconds', 'laneId', 'nodejs_eventloop_lag_p50_seconds', 'organization.id', 'workspace.id', 'service.name', 'nodejs_eventloop_lag_min_seconds', 'nodejs_eventloop_lag_max_seconds', 'peer.ipv4', 'nodejs_active_requests', 'nodejs_active_requests_total', 'nodejs_eventloop_lag_mean_seconds', 'err', 'nodejs_active_resources', 'telemetry.sdk.name', 'net.host.port', 'http.host', 'cloud.region', 'cloud.platform', 'nodejs_external_memory_bytes', 'link', 'net.host.name', 'api.endpoint', 'error', 'net.host.ip', 'span_id', 'nodejs_heap_space_size_available_bytes', 'net.peer.name', 'aws.region', 'cloud.account.id', 'net.peer.port', 'aws.ecs.cluster.arn', 'service.instance.id', 'searchResponse', 'nodejs_active_resources_total', 'workspaceId', 'nodejs_heap_space_size_total_bytes', 'span.kind', 'space', 'telemetry.instrumentation_library', 'net.peer.ip', 'container.cpu.onlines', 'cloud.availability_zone', 'telemetry.sdk.version', 'nodejs_active_handles', 'duration_ms', 'http.status_code', 'db.statement', 'http.route', 'parent_name', 'exception.message', 'name', 'trace.parent_id']",
"maxNewTokens": 5000,
"naturalLanguageQuery": "EMISSING endpoint analytics.service.com"
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json"
}
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json={"action_id": action_id, "inputs": payload} # Hypothetical structure
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error executing action {action_id}: {e}")
if e.response is not None:
print(f"Response status: {e.response.status_code}")
try:
print(f"Response body: {e.response.json()}")
except json.JSONDecodeError:
print(f"Response body: {e.response.text}")
In the above code snippet, replace the placeholder for your API key and ensure the endpoint URL aligns with your service specifications. The action ID for Generate Honeycomb NLQ is included, and the input payload is structured according to the action's requirements.
Conclusion
The Generate Honeycomb NLQ action provides a robust way to create Natural Language Queries for your Honeycomb data, facilitating more intuitive data interactions. By integrating this action into your applications, you can enhance your data analytics capabilities, enabling users to query data in a more natural, human-readable format. Consider exploring other actions within the Honeycomb API to further augment your data processing and analysis workflows. Happy coding!