Python 2.7 堆栈驱动程序度量导出

Python 2.7 堆栈驱动程序度量导出,python-2.7,google-app-engine,google-cloud-platform,google-cloud-pubsub,google-cloud-monitoring,Python 2.7,Google App Engine,Google Cloud Platform,Google Cloud Pubsub,Google Cloud Monitoring,环境:CloudShell 代码:python2.7 我想将指标从云监控导出到大查询,谷歌已经给出了一个解决方案。我在这篇文章中如下所述: 我已经从github下载了代码:https://github.com/GoogleCloudPlatform/stackdriver-metrics-export我正在遵循自述文件,并尝试在我的谷歌项目中运行该应用程序 当我安装并运行任何应用程序引擎时 https://get-timeseries-dot-managed-gcp.uc.r.appspot.

环境:CloudShell 代码:python2.7

我想将指标从云监控导出到大查询,谷歌已经给出了一个解决方案。我在这篇文章中如下所述:

我已经从github下载了代码:
https://github.com/GoogleCloudPlatform/stackdriver-metrics-export
我正在遵循自述文件,并尝试在我的谷歌项目中运行该应用程序

当我安装并运行任何应用程序引擎时
https://get-timeseries-dot-managed-gcp.uc.r.appspot.com/
/,我总是遇到这个错误500:

错误:服务器错误

The server encountered an error and could not complete your request.
Please try again in 30 seconds.
我查了一下日志,得到了他的

  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 
即使我还提供了项目id,也会出现此错误:

The supplied app engine url project does not match the subscription's parent project
由于上述错误,我无法完成pubsub订阅。我也搜索并运行了这个

sudo pip install --upgrade google-api-python-client
我使用的是Python2.7版本,在安装了上面的版本之后,我仍然可以

No module named googleapiclient.discovery

以前是否有人尝试过使用此代码?我对谷歌云和python都是全新的。
请帮助

从列表中捕获的应用引擎URL中删除区域id和“r”将允许您创建发布/订阅

github repo README.md已更新,以反映记录在案的应用程序引擎中区域id处理的变化

例如,列表\u度量\u URL为

# if this is your first app in your project
export LIST_METRICS_URL=https://$PROJECT_ID.appspot.com


从LIST_METRICS_URL中捕获的应用引擎URL中删除region_id和“r”将允许您创建发布/订阅

github repo README.md已更新,以反映记录在案的应用程序引擎中区域id处理的变化

例如,列表\u度量\u URL为

# if this is your first app in your project
export LIST_METRICS_URL=https://$PROJECT_ID.appspot.com


请分享
$LIST\u METRICS\u URL
的格式好吗?在某些情况下,Pub/Sub目前似乎无法很好地与区域AppEngine端点配合使用,这可能就是您遇到的情况。如果你有一个像
https://my-project-id.aa.b.appspot.com
,尝试将其替换为
https://my-project-id.appspot.com
。如果我将此url替换为仍然不起作用,并获取404 errorLIST_METRICS_url格式以供将来的读者使用,则发布/订阅现在支持创建对区域AppEngine端点的推送订阅。您好,我在write_METRICS应用程序写入数据库@type时经常遇到此错误:“type.googleapis.com/google.appengine.logging.v1.RequestLog”appEngineRelease:“1.9.71”appId:“s~managed prj”endTime:“2020-07-22T17:25:46.822457Z”完成:true first:true主机:“write metrics dot managed prj.appspot.com”延迟:“10.985283s”行:[:{logMessage:”在等待太长时间以尝试服务您的请求后,请求被中止。“严重性:“错误”时间:“2020-07-22T17:25:46.822446Z”}您能否共享
$LIST\u METRICS\u URL
的格式?在某些情况下,Pub/Sub目前似乎无法与区域AppEngine端点配合使用,这可能是您遇到的问题。如果您有类似
https://my-project-id.aa.b.appspot.com
,尝试将其替换为
https://my-project-id.appspot.com
。如果我将此url替换为仍然不起作用,并为将来的任何读者获取404 errorLIST\u METRICS\u url格式,则发布/订阅现在支持创建对区域AppEngine端点的推送订阅。您好,我在write\u METRICS应用程序写入数据库@type:时经常遇到此错误:type.googleapis.com/google.appengine.logging.v1.RequestLog“appEngineRelease:”1.9.71“appId:”s~managed prj“endTime:”2020-07-22T17:25:46.822457Z“finished:true first:true host:”write metrics dot managed prj.appspot.com“延迟:”10.985283s”行:[:{logMessage:”在等待太长时间以尝试服务您的请求后,请求被中止。“严重性:“错误”时间:“2020-07-22T17:25:46.822446Z”}非常感谢。我正面临此问题。在部署3个应用程序中的任何一个时,如果我以两种形式更改url,则会出现此错误或错误:未找到请求的url/未在此服务器上找到。从日志行:[0:{logMessage:“没有与此url匹配的处理程序。”严重性:“警告”时间:“2020-06-24T14:32:29.971283Z”}只有在我修改app.yaml并创建static/images文件夹并将此代码添加到handlers-url:/static\u files:static/images/favicon.ico下,才能避免此错误。上载:static/images/favicon.ico这可以避免吗,因为我必须在这里上传一张图片我对google cloud和python完全不熟悉,所以需要您在这里输入。谢谢“Error:Not Found”是预期的,因为代码专门针对从cloud Pub/Sub接收推送通知作为触发器,并且没有定义“/”目标接收请求。如果已部署云计划程序作业,则可以使用“运行测试”下列出的“gcloud Scheduler jobs run metric_export”运行该作业github README.md的部分。非常感谢。我面临这个问题。在部署3个应用程序中的任何一个时,如果我以两种形式更改url,则会出现此错误或错误:找不到请求的url/未在此服务器上找到。从日志行:[0:{logMessage:“没有处理程序匹配此url。”严重性:“警告”时间:“2020-06-24T14:32:29.971283Z”}只有在修改app.yaml并创建static/images文件夹并将此代码添加到handlers-url:/static_files:static/images/favicon.ico下,才能避免此错误。
# if this is not your first app in your project
export LIST_METRICS_URL=https://list-metrics-dot-$PROJECT_ID.appspot.com