chore(dedicated): Fixes DAR 453: customers can't enable tracing

Updates Cloud Dedicated docs to reflect current status of https://github.com/influxdata/EAR/issues/5677.
Fixes https://github.com/influxdata/DAR/issues/453.
  - Move trace to draft status
  - Remove trace-id from code sample
  - Use troubleshoot.md as alias for /influxdb/cloud-dedicated/query-data/troubleshoot-and-optimize/trace/
  - Add warning with note to contact support
  - Reorganize troubleshooting sections
pull/5697/head
Jason Stirnaman 2024-12-02 16:20:38 -06:00
parent 031080d632
commit 585280e3d5
4 changed files with 45 additions and 29 deletions

View File

@ -17,6 +17,7 @@ aliases:
- /influxdb/cloud-dedicated/query-data/execute-queries/optimize-queries/ - /influxdb/cloud-dedicated/query-data/execute-queries/optimize-queries/
- /influxdb/cloud-dedicated/query-data/execute-queries/analyze-query-plan/ - /influxdb/cloud-dedicated/query-data/execute-queries/analyze-query-plan/
- /influxdb/cloud-dedicated/query-data/optimize-queries/ - /influxdb/cloud-dedicated/query-data/optimize-queries/
--- ---
Optimize SQL and InfluxQL queries to improve performance and reduce their memory and compute (CPU) requirements. Optimize SQL and InfluxQL queries to improve performance and reduce their memory and compute (CPU) requirements.
@ -25,7 +26,6 @@ Learn how to use observability tools to analyze query execution and view metrics
- [Why is my query slow?](#why-is-my-query-slow) - [Why is my query slow?](#why-is-my-query-slow)
- [Strategies for improving query performance](#strategies-for-improving-query-performance) - [Strategies for improving query performance](#strategies-for-improving-query-performance)
- [Query only the data you need](#query-only-the-data-you-need) - [Query only the data you need](#query-only-the-data-you-need)
- [Analyze and troubleshoot queries](#analyze-and-troubleshoot-queries)
## Why is my query slow? ## Why is my query slow?
@ -87,11 +87,3 @@ If the table contains 10 columns, the difference in performance between the
two queries is minimal. two queries is minimal.
In a table with over 1000 columns, the `SELECT *` query is slower and In a table with over 1000 columns, the `SELECT *` query is slower and
less efficient. less efficient.
## Analyze and troubleshoot queries
Use the following tools to analyze and troubleshoot queries and find performance bottlenecks:
- [Analyze a query plan](/influxdb/cloud-dedicated/query-data/troubleshoot-and-optimize/analyze-query-plan/)
- [Enable trace logging for a query](/influxdb/cloud-dedicated/query-data/troubleshoot-and-optimize/trace/)
- [Retrieve `system.queries` information for a query](/influxdb/cloud-dedicated/query-data/troubleshoot-and-optimize/system-information/)

View File

@ -22,15 +22,10 @@ The information in each system table is scoped to the namespace you're querying;
you can only retrieve system information for that particular instance. you can only retrieve system information for that particular instance.
To get information about queries you've run on the current instance, use SQL to query the [`system.queries` table](/influxdb/cloud-dedicated/reference/internals/system-tables/#systemqueries-measurement), which contains information from the Querier instance currently handling queries. To get information about queries you've run on the current instance, use SQL to query the [`system.queries` table](/influxdb/cloud-dedicated/reference/internals/system-tables/#systemqueries-measurement), which contains information from the Querier instance currently handling queries.
If you [enabled trace logging](/influxdb/cloud-dedicated/query-data/troubleshoot-and-optimize/trace/) for the query, the `trace-id` appears in the `system.queries.trace_id` column for the query.
The `system.queries` table is an InfluxDB v3 **debug feature**. The `system.queries` table is an InfluxDB v3 **debug feature**.
To enable the feature and query `system.queries`, include an `"iox-debug"` header set to `"true"` and use SQL to query the table. To enable the feature and query `system.queries`, include an `"iox-debug"` header set to `"true"` and use SQL to query the table--for example:
The following sample code shows how to use the Python client library to do the following:
1. Enable tracing for a query.
2. Retrieve the trace ID record from `system.queries`.
<!-- Import for tests and hide from users. <!-- Import for tests and hide from users.
```python ```python
@ -54,13 +49,10 @@ def get_query_information():
host = f"{{< influxdb/host >}}", host = f"{{< influxdb/host >}}",
database = f"DATABASE_NAME") database = f"DATABASE_NAME")
random_bytes = secrets.token_bytes(16)
trace_id = random_bytes.hex()
trace_value = (f"{trace_id}:1112223334445:0:1").encode('utf-8')
sql = "SELECT * FROM home WHERE time >= now() - INTERVAL '30 days'" sql = "SELECT * FROM home WHERE time >= now() - INTERVAL '30 days'"
try: try:
client.query(sql, headers=[(b'influx-trace-id', trace_value)]) client.query(sql)
client.close() client.close()
except Exception as e: except Exception as e:
print("Query error: ", e) print("Query error: ", e)
@ -75,14 +67,13 @@ def get_query_information():
for i in range(0, 5): for i in range(0, 5):
time.sleep(1) time.sleep(1)
# Use SQL # Use SQL
# To query the system.queries table for your trace ID, pass the following: # To retrieve data about your query from the system.queries table, pass the following:
# - the iox-debug: true request header # - the iox-debug: true request header
# - an SQL query for the trace_id column # - an SQL query for system.queries
reader = client.query(f'''SELECT compute_duration, query_type, query_text, reader = client.query(f'''SELECT compute_duration, query_type, query_text,
success, trace_id success
FROM system.queries FROM system.queries
WHERE issue_time >= now() - INTERVAL '1 day' WHERE issue_time >= now() - INTERVAL '1 day'
AND trace_id = '{trace_id}'
ORDER BY issue_time DESC ORDER BY issue_time DESC
''', ''',
headers=[(b"iox-debug", b"true")], headers=[(b"iox-debug", b"true")],
@ -91,9 +82,18 @@ def get_query_information():
df = reader.read_all().to_pandas() df = reader.read_all().to_pandas()
if df.shape[0]: if df.shape[0]:
break break
# Adjust pandas display options to avoid truncating the output
assert df.shape == (1, 5), f"Expect a row for the query trace ID." # Filter the DataFrame to get rows where the column contains the query text
print(df) filtered_df = df[df['query_text'] == sql]
assert filtered_df.shape[0] > 0, "filtered_df should have at least 1 row"
# Specify system.queries columns to output
columns_to_output = ['compute_duration', 'query_text']
# Print row values for the specified columns
print(filtered_df[columns_to_output])
get_query_information() get_query_information()
``` ```
@ -102,7 +102,9 @@ get_query_information()
The output is similar to the following: The output is similar to the following:
```text
compute_duration query_type query_text success trace_id
0 days sql SELECT compute_duration, quer... True 67338...
``` ```
# Get query information
compute_duration query_text
3 0 days SELECT * FROM home WHERE time >= now() - INTER...
4 0 days SELECT * FROM home WHERE time >= now() - INTER...
```

View File

@ -12,8 +12,11 @@ related:
- /influxdb/cloud-dedicated/query-data/sql/ - /influxdb/cloud-dedicated/query-data/sql/
- /influxdb/cloud-dedicated/query-data/influxql/ - /influxdb/cloud-dedicated/query-data/influxql/
- /influxdb/cloud-dedicated/reference/client-libraries/v3/ - /influxdb/cloud-dedicated/reference/client-libraries/v3/
draft: true
--- ---
<!-- For draft status details, see https://github.com/influxdata/DAR/issues/453 -->
Learn how to enable trace logging to help you identify performance bottlenecks and troubleshoot problems in queries. Learn how to enable trace logging to help you identify performance bottlenecks and troubleshoot problems in queries.
When you enable trace logging for a query, InfluxDB propagates your _trace ID_ through system processes and collects additional log information. When you enable trace logging for a query, InfluxDB propagates your _trace ID_ through system processes and collects additional log information.

View File

@ -14,12 +14,14 @@ related:
- /influxdb/cloud-dedicated/reference/client-libraries/v3/ - /influxdb/cloud-dedicated/reference/client-libraries/v3/
aliases: aliases:
- /influxdb/cloud-dedicated/query-data/execute-queries/troubleshoot/ - /influxdb/cloud-dedicated/query-data/execute-queries/troubleshoot/
- /influxdb/cloud-dedicated/query-data/troubleshoot-and-optimize/trace/
--- ---
Troubleshoot SQL and InfluxQL queries that return unexpected results. Troubleshoot SQL and InfluxQL queries that return unexpected results.
- [Why doesn't my query return data?](#why-doesnt-my-query-return-data) - [Why doesn't my query return data?](#why-doesnt-my-query-return-data)
- [Optimize slow or expensive queries](#optimize-slow-or-expensive-queries) - [Optimize slow or expensive queries](#optimize-slow-or-expensive-queries)
- [Analyze query information](#analyze-query-information)
## Why doesn't my query return data? ## Why doesn't my query return data?
@ -48,4 +50,21 @@ If a query times out or returns an error, it might be due to the following:
If a query is slow or uses too many compute resources, limit the amount of data that it queries. If a query is slow or uses too many compute resources, limit the amount of data that it queries.
See how to [optimize queries](/influxdb/cloud-dedicated/query-data/troubleshoot-and-optimize/optimize-queries/) and use tools to view runtime metrics, identify bottlenecks, and debug queries. See how to [optimize queries](/influxdb/cloud-dedicated/query-data/troubleshoot-and-optimize/optimize-queries/)
## Analyze query information
Use the following tools to retrieve system query information, analyze query execution,
and find performance bottlenecks:
- [Analyze a query plan](/influxdb/cloud-dedicated/query-data/troubleshoot-and-optimize/analyze-query-plan/)
- [Retrieve `system.queries` information for a query](/influxdb/cloud-dedicated/query-data/troubleshoot-and-optimize/system-information/)
> [!Warn]
>
> #### Request help to troubleshoot queries
>
> Currently, customers can't enable trace logging for {{% product-name %}} clusters.
> For help troubleshooting a specific performance bottleneck or query
> problem, contact the
> [contact the InfluxData Support team](https://support.influxdata.com).