问题
Environment: CloudShell code : python2.7
I want to export Metrics from Cloud Monitoring to Big Query and google has given a solution on how to do this. I am following this in this below article: https://cloud.google.com/solutions/stackdriver-monitoring-metric-export
I have downloaded the code from github: https://github.com/GoogleCloudPlatform/stackdriver-metrics-export
and I am following the readme and trying to run the application in my google project.
When I install and run any of the app engines ex
https://get-timeseries-dot-managed-gcp.uc.r.appspot.com/
/, I always get this error 500:
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
In the logs i check and i get his
0: {
logMessage: "Traceback (most recent call last):
File "/base/data/home/apps/s~myproject/get-timeseries:20200623t152416.427592472816201321/main.py", line 23, in <module>
from googleapiclient.discovery import build
ImportError: No module named googleapiclient.discovery"
severity: "ERROR"
sourceLocation: {
file: "/base/alloc/tmpfs/dynamic_runtimes/python27g/534e28e62871e9ae/python27/python27_lib/versions/1/google/appengine/runtime/cgi.py"
functionName: "HandleRequest"
line: "123"
}
time: "2020-06-23T10:04:42.365030Z"
}
1: {
logMessage: "This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application."
severity: "INFO"
time: "2020-06-23T10:04:42.368883Z"
}
2: {
logMessage: "The warmup request failed. Please check your warmup handler implementation and make sure it's working correctly."
severity: "INFO"
time: "2020-06-23T10:04:42.368884Z"
}
3: {
logMessage: "Process terminated because it failed to respond to the start request with an HTTP status code of 200-299 or 404."
severity: "ERROR"
time: "2020-06-23T10:04:42.368885Z"
}
]
megaCycles: "241"
method: "GET"
moduleId: "get-timeseries"
requestId: "5ef1d3b500ff0ef7c1e4b283290001737e6d616e616765642d67637000016765742d74696d657365726965733a323032303036323374313532343136000100"
resource: "/_ah/start"
startTime: "2020-06-23T10:04:37.980929Z"
status: 500
traceId: "cc847beddcfade8728ae864d45761acd"
traceSampled: true
urlMapEntry: "main.py"
versionId: "20200623t152416"
wasLoadingRequest: true
. In app engine console the application is running in the services tab
Another issue is if i try to create a pub-sub subscription from cloudshellas mentioned in the source code like this after creating the topic:
gcloud pubsub subscriptions create metrics_export_start_sub --topic metrics_export_start --ack-deadline=60 --message-retention-duration=10m --push-endpoint="$LIST_METRICS_URL/_ah/push-handlers/receive_message"
I get this error even if i provide the project id also:
The supplied app engine url project does not match the subscription's parent project
Because of the above error I am not able to complete the pubsub subscriptions. i searched and ran this also
sudo pip install --upgrade google-api-python-client
I am using python 2.7 version and after installing the above still i am getting
No module named googleapiclient.discovery
Has anyone tried to use this code previously? I am totally new to google cloud and also to python. Kindly help
回答1:
Removing the region_id and the "r" from the App Engine URL captured in LIST_METRICS_URL will allow you to create the Pub/Sub subscription.
The github repo README.md has been updated to reflect the changes in handling of the region_id in App Engine which is documented here.
As an example, the LIST_METRICS_URL is either
# if this is your first app in your project
export LIST_METRICS_URL=https://$PROJECT_ID.appspot.com
OR
# if this is not your first app in your project
export LIST_METRICS_URL=https://list-metrics-dot-$PROJECT_ID.appspot.com
来源:https://stackoverflow.com/questions/62512711/stack-driver-metrics-export