// 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).
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.LoggingService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Logging
{
public class CreateUnifiedAgentConfigurationExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createUnifiedAgentConfigurationDetails = new Oci.LoggingService.Models.CreateUnifiedAgentConfigurationDetails
{
DisplayName = "EXAMPLE-displayName-Value",
IsEnabled = true,
ServiceConfiguration = new Oci.LoggingService.Models.UnifiedAgentLoggingConfiguration
{
Sources = new List<Oci.LoggingService.Models.UnifiedAgentLoggingSource>
{
new Oci.LoggingService.Models.UnifiedAgentTailLogSource
{
Paths = new List<string>
{
"EXAMPLE--Value"
},
Parser = new Oci.LoggingService.Models.UnifiedAgentApacheErrorParser
{
FieldTimeKey = "EXAMPLE-fieldTimeKey-Value",
Types = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_5avDh",
"EXAMPLE_VALUE_h2gVWkLtnCzBVVtPkpDV"
}
},
NullValuePattern = "EXAMPLE-nullValuePattern-Value",
IsNullEmptyString = false,
IsEstimateCurrentEvent = false,
IsKeepTimeKey = true,
TimeoutInMilliseconds = 437
},
AdvancedOptions = new Oci.LoggingService.Models.UnifiedAgentTailSourceAdvancedOptions
{
IsReadFromHead = false
},
Name = "EXAMPLE-name-Value"
}
},
Filter = new List<Oci.LoggingService.Models.UnifiedAgentLoggingFilter>
{
new Oci.LoggingService.Models.UnifiedAgentParserFilter
{
Parser = new Oci.LoggingService.Models.UnifiedAgentMsgpackParser
{
FieldTimeKey = "EXAMPLE-fieldTimeKey-Value",
Types = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_u6I12",
"EXAMPLE_VALUE_rvVIFDufKdq6wb5psL8t"
}
},
NullValuePattern = "EXAMPLE-nullValuePattern-Value",
IsNullEmptyString = false,
IsEstimateCurrentEvent = true,
IsKeepTimeKey = false,
TimeoutInMilliseconds = 581
},
KeyName = "EXAMPLE-keyName-Value",
ReserveTime = true,
ReserveData = false,
RemoveKeyNameField = true,
ReplaceInvalidSequence = true,
InjectKeyPrefix = "EXAMPLE-injectKeyPrefix-Value",
HashValueField = "EXAMPLE-hashValueField-Value",
EmitInvalidRecordToError = true,
Name = "EXAMPLE-name-Value"
}
},
Destination = new Oci.LoggingService.Models.UnifiedAgentLoggingDestination
{
LogObjectId = "ocid1.test.oc1..<unique_ID>EXAMPLE-logObjectId-Value",
OperationalMetricsConfiguration = new Oci.LoggingService.Models.OperationalMetricsConfiguration
{
Source = new Oci.LoggingService.Models.OperationalMetricsSource
{
Type = Oci.LoggingService.Models.OperationalMetricsSource.TypeEnum.UmaMetrics,
Metrics = new List<string>
{
"EXAMPLE--Value"
},
RecordInput = new Oci.LoggingService.Models.OperationalMetricsRecordInput
{
Namespace = "EXAMPLE-namespace-Value",
ResourceGroup = "EXAMPLE-resourceGroup-Value"
}
},
Destination = new Oci.LoggingService.Models.OperationalMetricsDestination
{
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"
}
}
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_EgsH4",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_DGPsW",
"EXAMPLE--Value"
}
}
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_1AcoA",
"EXAMPLE_VALUE_Ahd743VDQyj359zxii0R"
}
},
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
Description = "EXAMPLE-description-Value",
GroupAssociation = new Oci.LoggingService.Models.GroupAssociationDetails
{
GroupList = new List<string>
{
"EXAMPLE--Value"
}
}
};
var createUnifiedAgentConfigurationRequest = new Oci.LoggingService.Requests.CreateUnifiedAgentConfigurationRequest
{
CreateUnifiedAgentConfigurationDetails = createUnifiedAgentConfigurationDetails,
OpcRequestId = "4ZQCDTQFFTIKCYWK5LZZ<unique_ID>",
OpcRetryToken = "EXAMPLE-opcRetryToken-Value"
};
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
try
{
// Create a service client and send the request.
using (var client = new LoggingManagementClient(provider, new ClientConfiguration()))
{
var response = await client.CreateUnifiedAgentConfiguration(createUnifiedAgentConfigurationRequest);
// Retrieve value from the response.
var versionValue = response.httpResponseMessage.Version;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateUnifiedAgentConfiguration Failed with {e.Message}");
throw e;
}
}
}
}