// 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.UnifiedAgentSyslogParser
{
TimeFormat = "EXAMPLE-timeFormat-Value",
Rfc5424TimeFormat = "EXAMPLE-rfc5424TimeFormat-Value",
MessageFormat = Oci.LoggingService.Models.UnifiedAgentSyslogParser.MessageFormatEnum.Rfc3164,
IsWithPriority = true,
IsSupportColonlessIdent = true,
SyslogParserType = Oci.LoggingService.Models.UnifiedAgentSyslogParser.SyslogParserTypeEnum.Regexp,
FieldTimeKey = "EXAMPLE-fieldTimeKey-Value",
Types = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_jRasU",
"EXAMPLE_VALUE_7jwQnF5JlS7CqJHc9P84"
}
},
NullValuePattern = "EXAMPLE-nullValuePattern-Value",
IsNullEmptyString = true,
IsEstimateCurrentEvent = true,
IsKeepTimeKey = false,
TimeoutInMilliseconds = 778
},
AdvancedOptions = new Oci.LoggingService.Models.UnifiedAgentTailSourceAdvancedOptions
{
IsReadFromHead = false
},
Name = "EXAMPLE-name-Value"
}
},
Filter = new List<Oci.LoggingService.Models.UnifiedAgentLoggingFilter>
{
new Oci.LoggingService.Models.UnifiedAgentLoggingRecordTransformerFilter
{
RecordList = new List<Oci.LoggingService.Models.RecordTransformerPair>
{
new Oci.LoggingService.Models.RecordTransformerPair
{
Key = "EXAMPLE-key-Value",
Value = "EXAMPLE-value-Value"
}
},
IsRubyEnabled = false,
IsAutoTypecastEnabled = true,
IsRenewRecordEnabled = true,
RenewTimeKey = "EXAMPLE-renewTimeKey-Value",
KeepKeys = new List<string>
{
"EXAMPLE--Value"
},
RemoveKeys = new List<string>
{
"EXAMPLE--Value"
},
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_DMI3B",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_GGwd7",
"EXAMPLE--Value"
}
}
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_gTIjb",
"EXAMPLE_VALUE_laMlvCS1wwaC19KgGd8O"
}
},
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 = "JA5ELS9JOOVQPSSMF4KV<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;
}
}
}
}