当前位置: 首页>>代码示例>>Java>>正文


Java AWSLogsClient类代码示例

本文整理汇总了Java中com.amazonaws.services.logs.AWSLogsClient的典型用法代码示例。如果您正苦于以下问题:Java AWSLogsClient类的具体用法?Java AWSLogsClient怎么用?Java AWSLogsClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AWSLogsClient类属于com.amazonaws.services.logs包,在下文中一共展示了AWSLogsClient类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doStart

import com.amazonaws.services.logs.AWSLogsClient; //导入依赖的package包/类
@Override
protected void doStart() {
    logs = new AWSLogsClient(
            getCredentials(),
            getClientConfiguration()
    );
    logs.setRegion(RegionUtils.getRegion(region));
    if (!skipCreate) {
        if (!logGroupExists(logGroup)) {
            createLogGroup(logGroup);
        }
        if (!logStreamExists(logGroup, logStream)) {
            createLogStream(logGroup, logStream);
        }
    }
    queue = new LinkedBlockingQueue<>(internalQueueSize);
    worker = new Worker<>(this);
    worker.setName(format("%s-worker", getName()));
    worker.setDaemon(true);
    worker.start();
}
 
开发者ID:trautonen,项目名称:logback-ext,代码行数:22,代码来源:AbstractCloudWatchAppender.java

示例2: AWSLogsStub

import com.amazonaws.services.logs.AWSLogsClient; //导入依赖的package包/类
AWSLogsStub(String logGroupName, String logStreamName, String logRegion) {

        this.logGroupName = logGroupName;
        this.logStreamName = logStreamName;

        AWSLogs awsLogs = new AWSLogsClient();
        if (logRegion != null) {
            awsLogs.setRegion(RegionUtils.getRegion(logRegion));
        }
        this.awsLogs = awsLogs;
    }
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:12,代码来源:AWSLogsStub.java

示例3: CloudWatchMonitor

import com.amazonaws.services.logs.AWSLogsClient; //导入依赖的package包/类
public CloudWatchMonitor(AWSLogsClient client) {
    this.logsClient = client;
    if(!Validation.checkCloudWatchMonitorConfig(logsClient)) {
        latestLogs = Arrays.asList(failedConfigurationLogsMessage);
        return;
    }
    lastPollTime = 0L;
}
 
开发者ID:awslabs,项目名称:aws-codebuild-jenkins-plugin,代码行数:9,代码来源:CloudWatchMonitor.java

示例4: setAwsLogsClient

import com.amazonaws.services.logs.AWSLogsClient; //导入依赖的package包/类
void setAwsLogsClient(AWSLogsClient awsLogsClient) {
	this.awsLogsClient = awsLogsClient;
}
 
开发者ID:j256,项目名称:cloudwatch-logback-appender,代码行数:4,代码来源:CloudWatchAppender.java

示例5: testBasic

import com.amazonaws.services.logs.AWSLogsClient; //导入依赖的package包/类
@Test(timeout = 5000)
public void testBasic() throws InterruptedException {
	CloudWatchAppender appender = new CloudWatchAppender();
	AWSLogsClient awsLogClient = createMock(AWSLogsClient.class);
	appender.setAwsLogsClient(awsLogClient);

	appender.setMaxBatchSize(1);
	appender.setRegion("region");
	final String logGroup = "pfqoejpfqe";
	appender.setLogGroup(logGroup);
	final String logStream = "pffqjfqjpoqoejpfqe";
	appender.setLogStream(logStream);
	PatternLayout layout = new PatternLayout();
	layout.setContext(new LoggerContext());
	layout.setPattern("[%thread] %level %logger{20} - %msg%n%xThrowable");
	layout.start();
	appender.setLayout(layout);

	LoggingEvent event = new LoggingEvent();
	event.setTimeStamp(System.currentTimeMillis());
	String loggerName = "name";
	event.setLoggerName(loggerName);
	Level level = Level.DEBUG;
	event.setLevel(level);
	String message = "fjpewjfpewjfpewjfepowf";
	event.setMessage(message);

	String threadName = Thread.currentThread().getName();
	final String fullMessage = "[" + threadName + "] " + level + " " + loggerName + " - " + message + "\n";

	final PutLogEventsResult result = new PutLogEventsResult();
	String sequence = "ewopjfewfj";
	result.setNextSequenceToken(sequence);
	expect(awsLogClient.putLogEvents(isA(PutLogEventsRequest.class))).andAnswer(new IAnswer<PutLogEventsResult>() {
		@Override
		public PutLogEventsResult answer() {
			PutLogEventsRequest request = (PutLogEventsRequest) getCurrentArguments()[0];
			assertEquals(logGroup, request.getLogGroupName());
			assertEquals(logStream, request.getLogStreamName());
			List<InputLogEvent> events = request.getLogEvents();
			assertEquals(1, events.size());
			assertEquals(fullMessage, events.get(0).getMessage());
			return result;
		}
	}).times(2);
	awsLogClient.shutdown();

	// =====================================

	replay(awsLogClient);
	appender.start();
	// for coverage
	appender.start();
	appender.append(event);
	Thread.sleep(10);
	appender.append(event);
	while (appender.getEventsWrittenCount() < 2) {
		Thread.sleep(10);
	}
	appender.stop();
	verify(awsLogClient);
}
 
开发者ID:j256,项目名称:cloudwatch-logback-appender,代码行数:63,代码来源:CloudWatchAppenderTest.java

示例6: testMetricFilters

import com.amazonaws.services.logs.AWSLogsClient; //导入依赖的package包/类
@Ignore
@Test
public void testMetricFilters() {

    List<String> lines;

    PrintStream original = System.out;
    try {
        final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outputStream, true));

        Logger logger = LoggerFactory.getLogger("TEST-LOGGER");
        logger.info("TEST-MESSAGE");

        TestMetricSet metricSet = new TestMetricSet();
        MetricRegistry registry = new MetricRegistry();
        registry.registerAll(metricSet);

        metricSet.testCounter.inc();
        metricSet.testMeter.mark(1L);
        metricSet.testHistogram.update(1L);
        metricSet.testTimer.update(1L, TimeUnit.MINUTES);

        Slf4jReporter reporter = Slf4jReporter.forRegistry(registry)
                .markWith(MarkerFactory.getMarker("METRIC"))
                .outputTo(logger)
                .build();

        reporter.report();
        lines = Arrays.asList(outputStream.toString().split("\\n"));
    } finally {
        System.setOut(original);
    }

    assertNotNull(lines);

    AWSLogsClient client = new AWSLogsClient();

    // TODO: Loop for each kind of metric

    String metricFilterPattern =
            String.format(COMPLETE_FILTER_PATTERN_MAP.get("COUNTER"), "test.namespace/testCounter");

    TestMetricFilterRequest request = new TestMetricFilterRequest()
            .withFilterPattern(metricFilterPattern)
            .withLogEventMessages(lines);

    TestMetricFilterResult result = client.testMetricFilter(request);

    MetricFilterMatchRecord matchRecord = result.getMatches().get(0);
    assertEquals("test.namespace/testCounter", matchRecord.getExtractedValues().get("$name"));
    assertEquals("1", matchRecord.getExtractedValues().get("$count"));

    MetricFilterMatchRecord matchRecord2 = result.getMatches().get(1);
    assertEquals("test.namespace/testGauge", matchRecord2.getExtractedValues().get("$name"));
    assertEquals("42", matchRecord2.getExtractedValues().get("$value"));
}
 
开发者ID:symphoniacloud,项目名称:lambda-monitoring,代码行数:58,代码来源:CloudwatchMetricFilterTest.java

示例7: checkCloudWatchMonitorConfig

import com.amazonaws.services.logs.AWSLogsClient; //导入依赖的package包/类
public static boolean checkCloudWatchMonitorConfig(AWSLogsClient client) {
    if(client == null) {
        return false;
    }
    return true;
}
 
开发者ID:awslabs,项目名称:aws-codebuild-jenkins-plugin,代码行数:7,代码来源:Validation.java

示例8: getCloudWatchLogsClient

import com.amazonaws.services.logs.AWSLogsClient; //导入依赖的package包/类
public AWSLogsClient getCloudWatchLogsClient() throws InvalidInputException {
    AWSLogsClient client = new AWSLogsClient(awsCredentialsProvider, getClientConfiguration());
    client.setEndpoint("https://logs." + region + ".amazonaws.com");
    return client;
}
 
开发者ID:awslabs,项目名称:aws-codebuild-jenkins-plugin,代码行数:6,代码来源:AWSClientFactory.java

示例9: CloudWatchAppender

import com.amazonaws.services.logs.AWSLogsClient; //导入依赖的package包/类
private CloudWatchAppender(final String name,
                           final String awsLogGroupName,
                           final String awsLogStreamName,
                           final String awsLogStreamFlushPeriodInSeconds,
                           final Layout<Serializable> layout) {
    super(name, null, layout == null ? PatternLayout.createDefaultLayout() : layout, false);

    // figure out the flush period
    int flushPeriod = AWS_LOG_STREAM_FLUSH_PERIOD_IN_SECONDS;
    if (awsLogStreamFlushPeriodInSeconds != null) {
        try {
            flushPeriod = Integer.parseInt(awsLogStreamFlushPeriodInSeconds);
        } catch (NumberFormatException nfe) {
            debug("Bad awsLogStreamFlushPeriodInSeconds (" + awsLogStreamFlushPeriodInSeconds + "), defaulting to: " + AWS_LOG_STREAM_FLUSH_PERIOD_IN_SECONDS + "s");
        }
    } else {
        debug("No awsLogStreamFlushPeriodInSeconds specified, defaulted to " + AWS_LOG_STREAM_FLUSH_PERIOD_IN_SECONDS + "s");
    }
    flushPeriodMillis = flushPeriod * 1000;

    try {

        awsLogsClient = new AWSLogsClient(); // this should pull the credentials automatically from the environment

        // set the group name
        this.logGroupName = awsLogGroupName;

        // determine the stream name (prefix) and suffix it with the timestamp to ensure uniqueness
        String logStreamNamePrefix = awsLogStreamName;
        if (logStreamNamePrefix == null) {
            logStreamNamePrefix = ENV_LOG_STREAM_NAME;
        }
        if (logStreamNamePrefix == null) {
            logStreamNamePrefix = AWS_INSTANCE_ID;
        }
        String finalLogStreamName;
        do {
            finalLogStreamName = logStreamNamePrefix + " " + getTimeNow();
            this.sequenceTokenCache = createLogGroupAndLogStreamIfNeeded(logGroupName, finalLogStreamName);
        } while (this.sequenceTokenCache != null);
        logStreamName = finalLogStreamName;

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:Virtual-Instruments,项目名称:cloudwatch-log4j-appender,代码行数:47,代码来源:CloudWatchAppender.java

示例10: createAWSClient

import com.amazonaws.services.logs.AWSLogsClient; //导入依赖的package包/类
@Override
protected void createAWSClient()
{
    client = tryClientFactory(clientFactoryMethod, AWSLogs.class, true);
    if ((client == null) && (clientEndpoint == null))
    {
        client = tryClientFactory("com.amazonaws.services.logs.AWSLogsClientBuilder.defaultClient", AWSLogs.class, false);
    }
    if (client == null)
    {
        LogLog.debug(getClass().getSimpleName() + ": creating service client via constructor");
        client = tryConfigureEndpointOrRegion(new AWSLogsClient(), clientEndpoint);
    }
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:15,代码来源:CloudWatchLogWriter.java


注:本文中的com.amazonaws.services.logs.AWSLogsClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。