Visualizza le metriche del job
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Mostra come ottenere una raccolta di metriche che descrivono l'avanzamento di un job.
Esempio di codice
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis content provides code examples in C#, Go, Java, and Python that demonstrate how to retrieve a collection of metrics for a Dataflow job.\u003c/p\u003e\n"],["\u003cp\u003eThe code examples utilize the \u003ccode\u003eGetJobMetrics\u003c/code\u003e method from the Dataflow API.\u003c/p\u003e\n"],["\u003cp\u003eEach code snippet requires setting up Application Default Credentials for authentication with Dataflow and provides links to the setup documentation.\u003c/p\u003e\n"],["\u003cp\u003eEach of the snippets are code templates, meaning they need in-range values for initialization, along with specifying regional endpoints when creating the service client.\u003c/p\u003e\n"],["\u003cp\u003eThe content also gives a link to a Google Cloud sample browser to explore other code samples.\u003c/p\u003e\n"]]],[],null,["# Get job metrics\n\nDemonstrates how to get a collection of metrics describing the 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\n public sealed partial class GeneratedMetricsV1Beta3ClientSnippets\n {\n /// \u003csummary\u003eSnippet for GetJobMetrics\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 void GetJobMetricsRequestObject()\n {\n // Create client\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.MetricsV1Beta3Client.html metricsV1Beta3Client = 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_Create();\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 = metricsV1Beta3Client.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.MetricsV1Beta3Client.html#Google_Cloud_Dataflow_V1Beta3_MetricsV1Beta3Client_GetJobMetrics_Google_Cloud_Dataflow_V1Beta3_GetJobMetricsRequest_Google_Api_Gax_Grpc_CallSettings_(request);\n }\n }\n\n### Go\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 package main\n\n import (\n \t\"context\"\n\n \tdataflow \"cloud.google.com/go/dataflow/apiv1beta3\"\n \tdataflowpb \"cloud.google.com/go/dataflow/apiv1beta3/dataflowpb\"\n )\n\n func main() {\n \tctx := context.Background()\n \t// This snippet has been automatically generated and should be regarded as a code template only.\n \t// It will require modifications to work:\n \t// - It may require correct/in-range values for request initialization.\n \t// - It may require specifying regional endpoints when creating the service client as shown in:\n \t// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options\n \tc, err := dataflow.NewMetricsV1Beta3Client(ctx)\n \tif err != nil {\n \t\t// TODO: Handle error.\n \t}\n \tdefer c.Close()\n\n \treq := &dataflowpb.GetJobMetricsRequest{\n \t\t// TODO: Fill request struct fields.\n \t\t// See https://pkg.go.dev/cloud.google.com/go/dataflow/apiv1beta3/dataflowpb#GetJobMetricsRequest.\n \t}\n \tresp, err := c.GetJobMetrics(ctx, req)\n \tif err != nil {\n \t\t// TODO: Handle error.\n \t}\n \t// TODO: Use resp.\n \t_ = resp\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.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 SyncGetJobMetrics {\n\n public static void main(String[] args) throws Exception {\n syncGetJobMetrics();\n }\n\n public static void syncGetJobMetrics() 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.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 JobMetrics response = metricsV1Beta3Client.getJobMetrics(request);\n }\n }\n }\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 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.MetricsV1Beta3Client.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 = client.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.services.metrics_v1_beta3.MetricsV1Beta3Client.html#google_cloud_dataflow_v1beta3_services_metrics_v1_beta3_MetricsV1Beta3Client_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)."]]