pixie python API client always failed to validate the apikey
Describe the bug
I tried to connect self-hosted cloud with python API, and followed the instruction to generate apikey and cluster ID.
but the python sample code always failed with below errors:
Traceback (most recent call last):
File "/root/pixie-api-example/main.py", line 26, in
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem. Please make sure the screenshot does not contain any sensitive information such as API keys or access tokens.
import pxapi
def main(): # Create a Pixie client. px_client = pxapi.Client(token="px-api-03397708-2978-4710-9beb-e40e38096e57") # Connect to cluster. conn = px_client.connect_to_cluster("a355537a-8962-4b28-94ee-64e34479e912")
# Define a PxL query with one output table.
PXL_SCRIPT = """
import px
df = px.DataFrame('http_events')[['resp_status','req_path']]
df = df.head(10)
px.display(df, 'http_table')
"""
# Execute the PxL script.
script = conn.prepare_script(PXL_SCRIPT)
# Print the table output.
for row in script.results("http_table"):
print(row["resp_status"], row["req_path"])
if name == "main": main()
Logs Please attach the logs by running the following command:
./px collect-logs
App information (please complete the following information):
- Pixie version
- K8s cluster version
- Node Kernel version
- Browser version
Additional context Add any other context about the problem here.
I tried the apikey with/without the prefix of "px-api-", but all failed. I also unset the system proxy settings, but still no effect.
I added server_url to my self-hosted cloud, but failed with no certificaiton. px_client = pxapi.Client(token="px-api-03397708-2978-4710-9beb-e40e38096e57", server_url="dev.withpixie.dev", use_encryption=False)
Hi @everestplusteam, can you verify that your API key exists with the px cli. You can do so by running the following command:
$ PX_CLOUD_ADDR=dev.withpixie.dev:443 px api-key lookup
> Enter API Key (won't echo): <Enter your key in the prompt>
Please provide the output for that command once you've had a chance to run it.
it is my output, but I still cannot connect to with my API key.
I resolved the issue, as local cluster used, I need to set the cluster_address instead using the default value.