Jobmesswerte abrufen (asynchron)
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Zeigt, wie eine Sammlung von Messwerten abgerufen wird, die den detaillierten Fortschritt eines Jobs beschreiben.
Codebeispiel
Nächste Schritte
Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis content provides code examples in C#, Java, Node.js, and Python that demonstrate how to retrieve detailed metrics for a Dataflow job.\u003c/p\u003e\n"],["\u003cp\u003eThe code examples utilize the \u003ccode\u003eMetricsV1Beta3Client\u003c/code\u003e to make a \u003ccode\u003eGetJobMetrics\u003c/code\u003e request, specifying parameters such as \u003ccode\u003eProjectId\u003c/code\u003e, \u003ccode\u003eJobId\u003c/code\u003e, \u003ccode\u003eStartTime\u003c/code\u003e and \u003ccode\u003eLocation\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEach code snippet requires the setup of Application Default Credentials for authentication with Dataflow, referencing the "Set up authentication for a local development environment" documentation.\u003c/p\u003e\n"],["\u003cp\u003eThe examples are automatically generated code templates that will need to be modified with valid project and job IDs and other relevant data to run successfully.\u003c/p\u003e\n"]]],[],null,["# Get job metrics (async)\n\nDemonstrates how to get a collection of metrics describing the detailed progress of a job.\n\nCode sample\n-----------\n\n### C#\n\n\nTo authenticate to Dataflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n using https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.html;\n using https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.html;\n using System.Threading.Tasks;\n\n public sealed partial class GeneratedMetricsV1Beta3ClientSnippets\n {\n /// \u003csummary\u003eSnippet for GetJobMetricsAsync\u003c/summary\u003e\n /// \u003cremarks\u003e\n /// This snippet has been automatically generated and should be regarded as a code template only.\n /// It will require modifications to work:\n /// - It may require correct/in-range values for request initialization.\n /// - It may require specifying regional endpoints when creating the service client as shown in\n /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.\n /// \u003c/remarks\u003e\n public async Task GetJobMetricsRequestObjectAsync()\n {\n // Create client\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.MetricsV1Beta3Client.html metricsV1Beta3Client = await https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.MetricsV1Beta3Client.html.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.MetricsV1Beta3Client.html#Google_Cloud_Dataflow_V1Beta3_MetricsV1Beta3Client_CreateAsync_System_Threading_CancellationToken_();\n // Initialize request argument(s)\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.GetJobMetricsRequest.html request = new https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.GetJobMetricsRequest.html\n {\n ProjectId = \"\",\n JobId = \"\",\n StartTime = new https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Timestamp.html(),\n Location = \"\",\n };\n // Make the request\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.JobMetrics.html response = await metricsV1Beta3Client.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.MetricsV1Beta3Client.html#Google_Cloud_Dataflow_V1Beta3_MetricsV1Beta3Client_GetJobMetricsAsync_Google_Cloud_Dataflow_V1Beta3_GetJobMetricsRequest_Google_Api_Gax_Grpc_CallSettings_(request);\n }\n }\n\n### Java\n\n\nTo authenticate to Dataflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import com.google.api.core.https://cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.ApiFuture.html;\n import com.google.dataflow.v1beta3.GetJobMetricsRequest;\n import com.google.dataflow.v1beta3.JobMetrics;\n import com.google.dataflow.v1beta3.MetricsV1Beta3Client;\n import com.google.protobuf.https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Timestamp.html;\n\n public class AsyncGetJobMetrics {\n\n public static void main(String[] args) throws Exception {\n asyncGetJobMetrics();\n }\n\n public static void asyncGetJobMetrics() throws Exception {\n // This snippet has been automatically generated and should be regarded as a code template only.\n // It will require modifications to work:\n // - It may require correct/in-range values for request initialization.\n // - It may require specifying regional endpoints when creating the service client as shown in\n // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library\n try (MetricsV1Beta3Client metricsV1Beta3Client = MetricsV1Beta3Client.https://cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.SettableApiFuture.html#com_google_api_core_SettableApiFuture__V_create__()) {\n GetJobMetricsRequest request =\n GetJobMetricsRequest.newBuilder()\n .setProjectId(\"projectId-894832108\")\n .setJobId(\"jobId101296568\")\n .setStartTime(https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Timestamp.html.newBuilder().build())\n .setLocation(\"location1901043637\")\n .build();\n ApiFuture\u003cJobMetrics\u003e future =\n metricsV1Beta3Client.getJobMetricsCallable().futureCall(request);\n // Do something.\n JobMetrics response = future.get();\n }\n }\n }\n\n### Node.js\n\n\nTo authenticate to Dataflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n /**\n * This snippet has been automatically generated and should be regarded as a code template only.\n * It will require modifications to work.\n * It may require correct/in-range values for request initialization.\n * TODO(developer): Uncomment these variables before running the sample.\n */\n /**\n * A project id.\n */\n // const projectId = 'abc123'\n /**\n * The job to get metrics for.\n */\n // const jobId = 'abc123'\n /**\n * Return only metric data that has changed since this time.\n * Default is to return all information about all metrics for the job.\n */\n // const startTime = {}\n /**\n * The regional endpoint \n * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints) that\n * contains the job specified by job_id.\n */\n // const location = 'abc123'\n\n // Imports the Dataflow library\n const {MetricsV1Beta3Client} = require('https://cloud.google.com/nodejs/docs/reference/dataflow/latest/overview.html').v1beta3;\n\n // Instantiates a client\n const dataflowClient = new https://cloud.google.com/nodejs/docs/reference/dataflow/latest/overview.html();\n\n async function callGetJobMetrics() {\n // Construct request\n const request = {\n };\n\n // Run request\n const response = await dataflowClient.getJobMetrics(request);\n console.log(response);\n }\n\n callGetJobMetrics();\n\n### Python\n\n\nTo authenticate to Dataflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n # This snippet has been automatically generated and should be regarded as a\n # code template only.\n # It will require modifications to work:\n # - It may require correct/in-range values for request initialization.\n # - It may require specifying regional endpoints when creating the service\n # client as shown in:\n # https://googleapis.dev/python/google-api-core/latest/client_options.html\n from google.cloud import https://cloud.google.com/python/docs/reference/dataflow/latest/\n\n\n async def sample_get_job_metrics():\n # Create a client\n client = https://cloud.google.com/python/docs/reference/dataflow/latest/.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.services.metrics_v1_beta3.MetricsV1Beta3AsyncClient.html()\n\n # Initialize request argument(s)\n request = https://cloud.google.com/python/docs/reference/dataflow/latest/.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.types.GetJobMetricsRequest.html(\n )\n\n # Make the request\n response = await client.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.services.metrics_v1_beta3.MetricsV1Beta3AsyncClient.html#google_cloud_dataflow_v1beta3_services_metrics_v1_beta3_MetricsV1Beta3AsyncClient_get_job_metrics(request=request)\n\n # Handle the response\n print(response)\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=dataflow)."]]