// snippet-start:[CloudWatchLogs.dotnetv3.CreateExportTaskExample]
        public static async Task Main()
        {
            // This client object will be associated with the same AWS Region
            // as the default user on this system. If you need to use a
            // different AWS Region, pass it as a parameter to the client
            // constructor.
            var    client       = new AmazonCloudWatchLogsClient();
            string taskName     = "export-task-example";
            string logGroupName = "cloudwatchlogs-example-loggroup";
            string destination  = "doc-example-bucket";
            var    fromTime     = 1437584472382;
            var    toTime       = 1437584472833;

            var request = new CreateExportTaskRequest
            {
                From         = fromTime,
                To           = toTime,
                TaskName     = taskName,
                LogGroupName = logGroupName,
                Destination  = destination,
            };

            var response = await client.CreateExportTaskAsync(request);

            if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                Console.WriteLine($"The task, {taskName} with ID: {response.TaskId} has been created successfully.");
            }
        }
Esempio n. 2
0
 public async Task CreateLogExport(string logGroupName, string destinationS3Bucket, DateTime from, DateTime to, string destinationPrefix, string logStreamPrefix,
                                   string taskName = null)
 {
     if (taskName == null)
     {
         taskName = Guid.NewGuid().ToString();
     }
     await amazonCloudWatchLogsClient.CreateExportTaskAsync(new CreateExportTaskRequest()
     {
         Destination         = destinationS3Bucket,
         From                = (long)Math.Round((from - DateOrigin).TotalMilliseconds),
         To                  = (long)Math.Round((to - DateOrigin).TotalMilliseconds),
         LogGroupName        = logGroupName,
         DestinationPrefix   = destinationPrefix,
         LogStreamNamePrefix = string.IsNullOrEmpty(logStreamPrefix)?null:logStreamPrefix,
         TaskName            = taskName
     });
 }