# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).

import oci

# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()


# Initialize service client with default config file
apm_traces_client = oci.apm_traces.ScheduledQueryClient(config)


# Send the request to service, some parameters are not required, see API
# doc for more info
create_scheduled_query_response = apm_traces_client.create_scheduled_query(
    apm_domain_id="ocid1.test.oc1..<unique_ID>EXAMPLE-apmDomainId-Value",
    create_scheduled_query_details=oci.apm_traces.models.CreateScheduledQueryDetails(
        scheduled_query_name="EXAMPLE-scheduledQueryName-Value",
        scheduled_query_processing_type="EXPORT",
        scheduled_query_text="EXAMPLE-scheduledQueryText-Value",
        scheduled_query_schedule="EXAMPLE-scheduledQuerySchedule-Value",
        scheduled_query_description="EXAMPLE-scheduledQueryDescription-Value",
        scheduled_query_maximum_runtime_in_seconds=70,
        scheduled_query_retention_period_in_ms=19,
        scheduled_query_processing_sub_type="CUSTOM_METRIC",
        scheduled_query_processing_configuration=oci.apm_traces.models.ScheduledQueryProcessingConfig(
            streaming=oci.apm_traces.models.Streaming(
                stream_id="ocid1.test.oc1..<unique_ID>EXAMPLE-streamId-Value"),
            object_storage=oci.apm_traces.models.ObjectStorage(
                bucket_name="EXAMPLE-bucketName-Value",
                name_space="EXAMPLE-nameSpace-Value",
                object_name_prefix="EXAMPLE-objectNamePrefix-Value"),
            custom_metric=oci.apm_traces.models.CustomMetric(
                name="EXAMPLE-name-Value",
                namespace="EXAMPLE-namespace-Value",
                description="EXAMPLE-description-Value",
                resource_group="EXAMPLE-resourceGroup-Value",
                is_anomaly_detection_enabled=False,
                compartment="EXAMPLE-compartment-Value",
                unit="EXAMPLE-unit-Value",
                is_metric_published=False)),
        scheduled_query_retention_criteria="KEEP_DATA_UNTIL_RETENTION_PERIOD",
        freeform_tags={
            'EXAMPLE_KEY_OZLkW': 'EXAMPLE_VALUE_yG06ESQl7q8rrijMkL3A'},
        defined_tags={
            'EXAMPLE_KEY_DRkw0': {
                'EXAMPLE_KEY_OAnjB': 'EXAMPLE--Value'}}),
    opc_request_id="8Y1HEXMUS2L6ITFM6CSQ<unique_ID>",
    opc_retry_token="EXAMPLE-opcRetryToken-Value",
    opc_dry_run="EXAMPLE-opcDryRun-Value")

# Get the data from response
print(create_scheduled_query_response.data)

Was this article helpful?