├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ ├── Ask_Question.md │ └── Bug_Report.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── cloud_code_scan.yml ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── Dockerfile ├── Formatter.xml ├── HEADER ├── LICENSE ├── README.md ├── README_EN.md ├── boot ├── all-in-one-bootstrap │ ├── README-old.md │ ├── README.md │ ├── build.sh │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── all │ │ │ └── boot │ │ │ └── LookoutAllBootstrap.java │ │ └── resources │ │ ├── README.md │ │ └── app-configs │ │ ├── lookoutgateway │ │ ├── application-dev.properties │ │ └── application.properties │ │ └── lookoutserver │ │ ├── application-dev.properties │ │ └── application.properties ├── gateway-bootstrap │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── boot │ │ │ └── GatewayBootstrap.java │ │ └── resources │ │ └── application.properties ├── metrics-server-bootstrap │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── boot │ │ │ └── ServerBootstrap.java │ │ └── resources │ │ └── application.properties └── sofa-ark-support │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── alipay │ └── sofa │ └── lookout │ └── ark │ └── support │ ├── BootUtils.java │ ├── EnvUtils.java │ ├── SofaArkEmbedAppInitializer.java │ └── SofaArkEmbedUtils.java ├── check_format.sh ├── client ├── Formatter.xml ├── HEADER ├── README.md ├── README_EN.md ├── change_version.sh ├── lookout-api │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── lookout │ │ │ ├── api │ │ │ ├── BasicTag.java │ │ │ ├── BucketCounter.java │ │ │ ├── Clock.java │ │ │ ├── Counter.java │ │ │ ├── DefaultId.java │ │ │ ├── DistributionSummary.java │ │ │ ├── Gauge.java │ │ │ ├── Id.java │ │ │ ├── Indicator.java │ │ │ ├── Lookout.java │ │ │ ├── ManualClock.java │ │ │ ├── Measurement.java │ │ │ ├── Metric.java │ │ │ ├── MetricRegistry.java │ │ │ ├── NoopCounter.java │ │ │ ├── NoopDistributionSummary.java │ │ │ ├── NoopGauge.java │ │ │ ├── NoopId.java │ │ │ ├── NoopInfo.java │ │ │ ├── NoopMixinMetric.java │ │ │ ├── NoopRegistry.java │ │ │ ├── NoopTimer.java │ │ │ ├── PRIORITY.java │ │ │ ├── Registry.java │ │ │ ├── ResettableStep.java │ │ │ ├── Statistic.java │ │ │ ├── Tag.java │ │ │ ├── TagSet.java │ │ │ ├── Timer.java │ │ │ ├── Utils.java │ │ │ ├── composite │ │ │ │ ├── CompositeCounter.java │ │ │ │ ├── CompositeDistributionSummary.java │ │ │ │ ├── CompositeMetric.java │ │ │ │ ├── CompositeMixinMetric.java │ │ │ │ ├── CompositeRegistry.java │ │ │ │ ├── CompositeTimer.java │ │ │ │ └── MixinMetric.java │ │ │ └── info │ │ │ │ ├── AutoPollFriendlyInfo.java │ │ │ │ ├── AutoPollSuggestion.java │ │ │ │ └── Info.java │ │ │ ├── common │ │ │ ├── Assert.java │ │ │ ├── LookoutConstants.java │ │ │ └── top │ │ │ │ ├── AbstractTopMetric.java │ │ │ │ ├── DefaultTopGauger.java │ │ │ │ ├── NoopTopGauger.java │ │ │ │ ├── RollableTopGauge.java │ │ │ │ ├── TopGauger.java │ │ │ │ └── TopUtil.java │ │ │ └── jdk8 │ │ │ └── Function.java │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── lookout │ │ └── api │ │ ├── BasicTagTest.java │ │ ├── DefaultIdTest.java │ │ ├── IndicatorTest.java │ │ ├── LookoutTest.java │ │ ├── ManualClockTest.java │ │ ├── NoopRegistryTest.java │ │ ├── TagSetTest.java │ │ ├── UtilsTest.java │ │ ├── composite │ │ └── CompositeRegistryTest.java │ │ └── info │ │ └── AutoPollSuggestionTest.java ├── lookout-client │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── lookout │ │ │ └── client │ │ │ ├── AbstractLookoutClient.java │ │ │ ├── DefaultLookoutClient.java │ │ │ ├── LookoutClient.java │ │ │ ├── PollerUtils.java │ │ │ └── SimpleLookoutClient.java │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── lookout │ │ └── client │ │ ├── DefaultLookoutClientTest.java │ │ ├── MetricsHttpExporterTest.java │ │ └── SimpleLookoutClientTest.java ├── lookout-common │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── lookout │ │ │ │ └── common │ │ │ │ ├── log │ │ │ │ └── LookoutLoggerFactory.java │ │ │ │ └── utils │ │ │ │ ├── ClassUtil.java │ │ │ │ ├── CommonUtil.java │ │ │ │ ├── NetworkUtil.java │ │ │ │ └── PriorityTagUtil.java │ │ └── resources │ │ │ └── com │ │ │ └── alipay │ │ │ └── lookout │ │ │ └── log │ │ │ ├── log4j │ │ │ └── log-conf.xml │ │ │ ├── log4j2 │ │ │ └── log-conf.xml │ │ │ └── logback │ │ │ └── log-conf.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── lookout │ │ └── common │ │ └── utils │ │ ├── ClassUtilTest.java │ │ ├── LookoutLoggerFactoryTest.java │ │ ├── NetworkUtilTest.java │ │ └── PriorityTagUtilTest.java ├── lookout-core │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── lookout │ │ │ ├── core │ │ │ ├── AbstractRegistry.java │ │ │ ├── AbstractTimer.java │ │ │ ├── CommonTagsAccessor.java │ │ │ ├── DefaultCounter.java │ │ │ ├── DefaultDistributionSummary.java │ │ │ ├── DefaultMixinMetric.java │ │ │ ├── DefaultRegistry.java │ │ │ ├── DefaultTimer.java │ │ │ ├── GaugeWrapper.java │ │ │ ├── InfoWrapper.java │ │ │ ├── MetricIterable.java │ │ │ ├── MetricIterator.java │ │ │ ├── NoopCounter.java │ │ │ ├── NoopDistributionSummary.java │ │ │ ├── NoopGauge.java │ │ │ ├── NoopId.java │ │ │ ├── NoopInfo.java │ │ │ ├── NoopMixinMetric.java │ │ │ ├── NoopTimer.java │ │ │ ├── common │ │ │ │ ├── MeasurementUtil.java │ │ │ │ └── NewMetricFunction.java │ │ │ └── config │ │ │ │ ├── LookoutConfig.java │ │ │ │ └── MetricConfig.java │ │ │ ├── event │ │ │ └── MetricRegistryListener.java │ │ │ ├── remote │ │ │ └── model │ │ │ │ └── LookoutMeasurement.java │ │ │ ├── report │ │ │ ├── AbstractPoller.java │ │ │ ├── LogObserver.java │ │ │ ├── MetricObserver.java │ │ │ ├── MetricPoller.java │ │ │ └── filter │ │ │ │ └── PriorityMetricFilter.java │ │ │ ├── spi │ │ │ ├── MetricFilter.java │ │ │ ├── MetricsImporter.java │ │ │ └── MetricsImporterLocator.java │ │ │ └── step │ │ │ ├── AtomicDouble.java │ │ │ ├── MeasurableScheduler.java │ │ │ ├── ScheduledService.java │ │ │ ├── StepDouble.java │ │ │ ├── StepLong.java │ │ │ └── StepValue.java │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── lookout │ │ ├── MockId.java │ │ ├── api │ │ ├── RegistryTest.java │ │ └── composite │ │ │ ├── CompositeMetricTest.java │ │ │ └── DefaultMixinMetricTest.java │ │ ├── common │ │ └── MeasurementUtilTest.java │ │ ├── config │ │ └── InfoWrapperTest.java │ │ ├── core │ │ ├── DefaultCounterTest.java │ │ ├── DefaultDistributionSummaryTest.java │ │ ├── DefaultRegistryTest.java │ │ └── PriorityMetricFilterTest.java │ │ ├── remote │ │ └── LookoutMeasurementTest.java │ │ ├── report │ │ └── LogObserverTest.java │ │ ├── spi │ │ └── DefaultMetricsImporterLocatorTest.java │ │ ├── step │ │ ├── AtomicDoubleTest.java │ │ ├── MeasurableSchedulerTest.java │ │ ├── StepDoubleTest.java │ │ └── StepLongTest.java │ │ └── top │ │ └── TopUtilTest.java ├── lookout-ext-jvm │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── lookout │ │ │ │ ├── BasicMetricsImporter.java │ │ │ │ ├── FileSystemSpaceMetricsImporter.java │ │ │ │ └── jvm │ │ │ │ ├── JvmClassesMetricsImporter.java │ │ │ │ ├── JvmGcMetricsImporter.java │ │ │ │ ├── JvmMemoryMetricsImporter.java │ │ │ │ ├── JvmSystemPropertiesInfoMetricImporter.java │ │ │ │ ├── JvmThreadsMetricsImporter.java │ │ │ │ └── LookoutIdNameConstants.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── services │ │ │ └── com.alipay.lookout.spi.MetricsImporter │ │ └── test │ │ └── java │ │ ├── com.alipay.lookout.jvm.memory │ │ └── JvmInfoMetricsImporterTest.java │ │ └── com │ │ └── alipay │ │ └── lookout │ │ └── jvm │ │ └── JvmSystemPropertiesInfoMetricImporterTest.java ├── lookout-ext-os │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── lookout │ │ │ │ └── os │ │ │ │ ├── CachedMetricsImporter.java │ │ │ │ ├── linux │ │ │ │ ├── CpuUsageMetricsImporter.java │ │ │ │ ├── DiskUsageMetricsImporter.java │ │ │ │ ├── IOStatsMetricsImporter.java │ │ │ │ ├── MemoryStatsMetricsImporter.java │ │ │ │ ├── NetTrafficMetricsImporter.java │ │ │ │ └── SystemLoadMetricsImporter.java │ │ │ │ └── utils │ │ │ │ ├── FileUtils.java │ │ │ │ └── NumFormatUtils.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── services │ │ │ └── com.alipay.lookout.spi.MetricsImporter │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── lookout │ │ │ └── os │ │ │ └── linux │ │ │ ├── CpuUsageMetricsImporterTest.java │ │ │ ├── DiskUsageMetricsImporterTest.java │ │ │ ├── IOStatsMetricsImporterTest.java │ │ │ ├── MemoryStatsMetricsImporterTest.java │ │ │ ├── NetTrafficMetricsImporterTest.java │ │ │ └── SystemLoadMetricsImporterTest.java │ │ └── resources │ │ ├── proc_diskstats_1 │ │ ├── proc_diskstats_2 │ │ ├── proc_loadavg │ │ ├── proc_meminfo │ │ ├── proc_mounts │ │ ├── proc_net_dev │ │ ├── proc_stat │ │ ├── proc_uptime_1 │ │ └── proc_uptime_2 ├── lookout-reg-dropwizard │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── lookout │ │ │ └── dropwizard │ │ │ └── metrics │ │ │ ├── DWMetricsGuage.java │ │ │ ├── DropWizardMetricsRegistry.java │ │ │ ├── DwMetricWrapper.java │ │ │ ├── DwMetricsCounter.java │ │ │ ├── DwMetricsDistributionSummary.java │ │ │ ├── DwMetricsMixin.java │ │ │ ├── DwMetricsTimer.java │ │ │ └── NameUtils.java │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── lookout │ │ └── dropwizard │ │ └── metrics │ │ ├── DropWizardMetricsRegistryTest.java │ │ └── NameUtilsTest.java ├── lookout-reg-prometheus │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── lookout │ │ │ └── reg │ │ │ └── prometheus │ │ │ ├── PrometheusRegistry.java │ │ │ ├── common │ │ │ └── PromWriter.java │ │ │ └── exporter │ │ │ └── ExporterServer.java │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── lookout │ │ └── reg │ │ └── prometheus │ │ ├── ExporterServerTest.java │ │ ├── PromWriterTest.java │ │ └── PrometheusRegistryTest.java ├── lookout-reg-server │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── lookout │ │ │ ├── common │ │ │ └── MetricObserverUtil.java │ │ │ └── remote │ │ │ ├── report │ │ │ ├── Address.java │ │ │ ├── AddressService.java │ │ │ ├── DefaultAddressService.java │ │ │ ├── HttpObserver.java │ │ │ ├── MetricObserverMeasurementsFilter.java │ │ │ ├── PriorityMetricsCache.java │ │ │ ├── ReScheduleSupport.java │ │ │ ├── SchedulerPoller.java │ │ │ ├── poller │ │ │ │ ├── Listener.java │ │ │ │ ├── MetricCache.java │ │ │ │ ├── MetricDto.java │ │ │ │ ├── MetricsHttpExporter.java │ │ │ │ ├── PollerController.java │ │ │ │ └── Slot.java │ │ │ └── support │ │ │ │ └── http │ │ │ │ ├── DefaultHttpRequestProcessor.java │ │ │ │ ├── HttpRequestProcessor.java │ │ │ │ ├── ReportConfig.java │ │ │ │ ├── ReportConfigUtil.java │ │ │ │ ├── ReportDecider.java │ │ │ │ └── ResultConsumer.java │ │ │ └── step │ │ │ ├── LookoutBucketCounter.java │ │ │ ├── LookoutCounter.java │ │ │ ├── LookoutDistributionSummary.java │ │ │ ├── LookoutMixinMetric.java │ │ │ ├── LookoutRegistry.java │ │ │ ├── LookoutTimer.java │ │ │ ├── MetricObserverComposite.java │ │ │ ├── PollableInfoWrapper.java │ │ │ ├── ResettableStepRegistry.java │ │ │ ├── StepClock.java │ │ │ └── StepRegistry.java │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── lookout │ │ │ ├── MockHttpRequestProcessor.java │ │ │ ├── common │ │ │ └── MetricObserverUtilTest.java │ │ │ └── remote │ │ │ ├── HttpObserverTest.java │ │ │ ├── report │ │ │ ├── DefaultAddressServiceTest.java │ │ │ ├── HttpObserverTest.java │ │ │ ├── LookoutMeasurementTest.java │ │ │ ├── ReScheduleSupportTest.java │ │ │ ├── RealAgentServerUrlTest.java │ │ │ ├── poller │ │ │ │ ├── MetricCacheTest.java │ │ │ │ └── PollerControllerTest.java │ │ │ └── support │ │ │ │ ├── HttpRequestProcessorTest.java │ │ │ │ ├── JsonStringfyTest.java │ │ │ │ └── http │ │ │ │ ├── DefaultHttpRequestProcessorTest.java │ │ │ │ ├── ReportConfigUtilTest.java │ │ │ │ └── ReportDeciderTest.java │ │ │ └── step │ │ │ ├── CompositeRegistryTest.java │ │ │ ├── LookoutCounterTest.java │ │ │ ├── LookoutMetricTest.java │ │ │ ├── LookoutRegistryTest.java │ │ │ ├── LookoutTimerTest.java │ │ │ ├── MetricObserverCompositeTest.java │ │ │ ├── MockClock.java │ │ │ ├── PollableInfoWrapperTest.java │ │ │ ├── SchedulerMultiTaskTest.java │ │ │ └── TopGaugerTest.java │ │ └── resources │ │ └── log4j.xml ├── lookout-sofa-boot-starter │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── lookout │ │ │ │ └── starter │ │ │ │ ├── LookoutClientProperties.java │ │ │ │ ├── autoConfiguration │ │ │ │ └── LookoutAutoConfiguration.java │ │ │ │ ├── configuration │ │ │ │ └── MetricsActuatorAutoConfiguration.java │ │ │ │ └── support │ │ │ │ ├── LookoutApplicationContextInitializer.java │ │ │ │ ├── MetricConfigCustomizer.java │ │ │ │ ├── actuator │ │ │ │ ├── LookoutSpringBootMetricsImpl.java │ │ │ │ └── SpringBootActuatorRegistry.java │ │ │ │ ├── converter │ │ │ │ └── IndicatorConvert.java │ │ │ │ ├── reader │ │ │ │ └── LookoutRegistryMetricReader.java │ │ │ │ └── reg │ │ │ │ ├── DropWizardMetricsRegistryFactory.java │ │ │ │ ├── LookoutServerRegistryFactory.java │ │ │ │ ├── MetricsRegistryFactory.java │ │ │ │ ├── PrometheusMetricsRegistryFactory.java │ │ │ │ └── SpringBootActuatorRegistryFactory.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── spring.factories │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── lookout │ │ │ └── starter │ │ │ ├── LookoutStarterTest.java │ │ │ ├── base │ │ │ ├── AbstractTestBase.java │ │ │ └── SpringBootWebApplication.java │ │ │ └── support │ │ │ ├── MetricConfigCustomizerConfig.java │ │ │ ├── MetricConfigCustomizerTest.java │ │ │ ├── actuator │ │ │ └── LookoutSpringBootMetricsImplTest.java │ │ │ ├── reader │ │ │ └── LookoutRegistryMetricReaderTest.java │ │ │ └── reg │ │ │ └── LookoutServerRegistryFactoryTest.java │ │ └── resources │ │ ├── application-metrics.properties │ │ ├── application-reader.properties │ │ └── application.properties └── pom.xml ├── docker ├── README.md ├── entrypoint.sh └── settings-aliyun.xml ├── gateway ├── core │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── gateway │ │ │ └── core │ │ │ ├── common │ │ │ ├── ConditionalOnMonitorComponent.java │ │ │ ├── Constants.java │ │ │ ├── CoolDown.java │ │ │ ├── DataType.java │ │ │ ├── Executors.java │ │ │ ├── LogUtils.java │ │ │ ├── MonitorComponent.java │ │ │ ├── MonitorComponentConditional.java │ │ │ ├── RefuseRequestService.java │ │ │ ├── TimeUtil.java │ │ │ ├── WebfluxUtils.java │ │ │ └── impl │ │ │ │ └── RefuseRequestServiceImpl.java │ │ │ ├── prototype │ │ │ ├── exporter │ │ │ │ ├── AbstractBatchExporter.java │ │ │ │ ├── AbstractExporter.java │ │ │ │ ├── ConditionalOnExporterComponent.java │ │ │ │ ├── ExportChainManager.java │ │ │ │ ├── Exporter.java │ │ │ │ ├── buffer │ │ │ │ │ ├── Buffer.java │ │ │ │ │ └── impl │ │ │ │ │ │ ├── AbstractBuffer.java │ │ │ │ │ │ ├── LockBuffer.java │ │ │ │ │ │ └── ThreadLocalBuffer.java │ │ │ │ └── chain │ │ │ │ │ ├── AbstractExportChain.java │ │ │ │ │ ├── ExportChain.java │ │ │ │ │ └── ipml │ │ │ │ │ └── StaticExportChain.java │ │ │ ├── filter │ │ │ │ ├── AbstractFilter.java │ │ │ │ ├── AbstractFilterManager.java │ │ │ │ ├── Filter.java │ │ │ │ ├── FilterManager.java │ │ │ │ ├── PostFilterManager.java │ │ │ │ ├── PreFilterManager.java │ │ │ │ └── parser │ │ │ │ │ ├── FilterException.java │ │ │ │ │ └── FilterParser.java │ │ │ ├── importer │ │ │ │ ├── AbstractImporter.java │ │ │ │ ├── ConditionalOnImporterComponent.java │ │ │ │ └── Importer.java │ │ │ ├── lifecycle │ │ │ │ ├── LifeCycle.java │ │ │ │ └── LifeCycleSupport.java │ │ │ ├── pipeline │ │ │ │ ├── AbstractProcessor.java │ │ │ │ ├── ImporterExporterComponentConditional.java │ │ │ │ ├── ImporterProcessor.java │ │ │ │ ├── NoInputProcessor.java │ │ │ │ └── Processor.java │ │ │ ├── queue │ │ │ │ ├── BasePersistQueueProcessor.java │ │ │ │ ├── DequeueThread.java │ │ │ │ └── Serializer.java │ │ │ └── reader │ │ │ │ ├── AbstractReader.java │ │ │ │ └── Reader.java │ │ │ ├── queue │ │ │ ├── MappedFilePersistentQueue.java │ │ │ └── Writable.java │ │ │ ├── ratelimit │ │ │ ├── RateLimitService.java │ │ │ └── impl │ │ │ │ ├── ConfigurationRateLimitConfigProvider.java │ │ │ │ ├── ProviderBasedRateLimitServiceImpl.java │ │ │ │ ├── RateLimitConfigProvider.java │ │ │ │ ├── RateLimitServiceImpl.java │ │ │ │ └── UnlimitedRateLimitService.java │ │ │ ├── reader │ │ │ └── InputMessageReaderManager.java │ │ │ ├── scrape │ │ │ ├── DefaultScrapeManager.java │ │ │ ├── JobBuilder.java │ │ │ ├── JobConfigResolver.java │ │ │ ├── JobProcessor.java │ │ │ ├── JobState.java │ │ │ ├── ScrapeJob.java │ │ │ ├── ScrapeManager.java │ │ │ ├── ScrapeResult.java │ │ │ └── config │ │ │ │ ├── BaseConfig.java │ │ │ │ └── ScrapeConfig.java │ │ │ ├── token │ │ │ ├── LookoutTokenResolveUtils.java │ │ │ ├── LookoutTokenService.java │ │ │ └── impl │ │ │ │ └── NoopLookoutTokenService.java │ │ │ └── utils │ │ │ ├── BlockExecutionHandler.java │ │ │ ├── DigestLogUtil.java │ │ │ ├── JsonUtils.java │ │ │ ├── ListUtils.java │ │ │ └── MapUtils.java │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── lookout │ │ └── gateway │ │ └── core │ │ ├── common │ │ ├── MonitorComponentConditionalTest.java │ │ ├── TimeUtilTest.java │ │ ├── WebfluxUtilsTest.java │ │ └── impl │ │ │ └── RefuseRequestServiceImplTest.java │ │ ├── queue │ │ └── MappedFilePersistentQueueTest.java │ │ └── token │ │ └── LookoutTokenResolveUtilsTest.java ├── metrics │ ├── exporter │ │ ├── elasticsearch │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── alipay │ │ │ │ │ └── sofa │ │ │ │ │ └── lookout │ │ │ │ │ └── gateway │ │ │ │ │ └── metrics │ │ │ │ │ └── exporter │ │ │ │ │ └── es │ │ │ │ │ ├── ESConverter.java │ │ │ │ │ ├── ESEntity.java │ │ │ │ │ ├── ESMetricExporter.java │ │ │ │ │ ├── ESProperties.java │ │ │ │ │ ├── common │ │ │ │ │ └── ESConsts.java │ │ │ │ │ └── spring │ │ │ │ │ └── bean │ │ │ │ │ └── config │ │ │ │ │ └── EsExporterConfiguration.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com.alipay.sofa.lookout.gateway.metrics.exporter.es │ │ │ │ └── ESConverterTest.java │ │ └── standard │ │ │ ├── pom.xml │ │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── gateway │ │ │ └── metrics │ │ │ └── exporter │ │ │ └── standard │ │ │ ├── RelayMetricExporterProperties.java │ │ │ ├── StandardMetricExporter.java │ │ │ └── spring │ │ │ └── bean │ │ │ └── config │ │ │ └── RelayExporterConfiguration.java │ ├── importer │ │ ├── metricbeat │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── alipay │ │ │ │ │ └── sofa │ │ │ │ │ └── lookout │ │ │ │ │ └── gateway │ │ │ │ │ └── metrics │ │ │ │ │ └── importer │ │ │ │ │ └── metricbeat │ │ │ │ │ ├── MetricbeatMetricImporter.java │ │ │ │ │ ├── MetricbeatMetricReader.java │ │ │ │ │ └── spring │ │ │ │ │ └── bean │ │ │ │ │ └── config │ │ │ │ │ └── MetricbeatImporterConfiguration.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── sofa │ │ │ │ └── lookout │ │ │ │ └── gateway │ │ │ │ └── metrics │ │ │ │ └── importer │ │ │ │ └── metricbeat │ │ │ │ └── MetricbeatMetricReaderTest.java │ │ ├── opentsdb │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── alipay │ │ │ │ │ └── sofa │ │ │ │ │ └── lookout │ │ │ │ │ └── gateway │ │ │ │ │ └── metrics │ │ │ │ │ └── importer │ │ │ │ │ └── opentsdb │ │ │ │ │ ├── OpentsdbConverter.java │ │ │ │ │ ├── OpentsdbMetricImporter.java │ │ │ │ │ ├── OpentsdbMetricReader.java │ │ │ │ │ └── spring │ │ │ │ │ └── bean │ │ │ │ │ └── config │ │ │ │ │ └── OpentsdbImporterConfiguration.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── sofa │ │ │ │ └── lookout │ │ │ │ └── gateway │ │ │ │ └── metrics │ │ │ │ └── importer │ │ │ │ └── opentsdb │ │ │ │ ├── OpentsdbConverterTest.java │ │ │ │ └── OpentsdbMetricReaderTest.java │ │ ├── prometheus │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── alipay │ │ │ │ │ └── sofa │ │ │ │ │ └── lookout │ │ │ │ │ └── gateway │ │ │ │ │ └── metrics │ │ │ │ │ └── importer │ │ │ │ │ └── prometheus │ │ │ │ │ ├── PrometheusConverter.java │ │ │ │ │ ├── PrometheusMetricImporter.java │ │ │ │ │ ├── PrometheusMetricReader.java │ │ │ │ │ ├── scrape │ │ │ │ │ ├── PromJobConfigResolver.java │ │ │ │ │ ├── PromScrapeJobBuilder.java │ │ │ │ │ ├── StaticScrapeConfig.java │ │ │ │ │ └── StaticTargetPromScrapeJob.java │ │ │ │ │ └── spring │ │ │ │ │ └── bean │ │ │ │ │ └── config │ │ │ │ │ └── PrometheusImporterConfiguration.java │ │ │ │ └── test │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── alipay │ │ │ │ │ └── sofa │ │ │ │ │ └── lookout │ │ │ │ │ └── gateway │ │ │ │ │ └── metrics │ │ │ │ │ └── importer │ │ │ │ │ └── prometheus │ │ │ │ │ └── scrape │ │ │ │ │ ├── PrometheusConverterTest.java │ │ │ │ │ ├── PrometheusMetricReaderTest.java │ │ │ │ │ └── StaticTargetScrapeTest.java │ │ │ │ └── resources │ │ │ │ └── static_targets_config.yml │ │ └── standard │ │ │ ├── pom.xml │ │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── gateway │ │ │ └── metrics │ │ │ └── importer │ │ │ └── standard │ │ │ ├── StandardMetricConverter.java │ │ │ ├── StandardMetricImporter.java │ │ │ ├── StandardMetricReader.java │ │ │ └── spring │ │ │ └── bean │ │ │ └── config │ │ │ └── StandardImporterConfiguration.java │ ├── pipeline │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── sofa │ │ │ │ └── lookout │ │ │ │ └── gateway │ │ │ │ └── metrics │ │ │ │ └── pipeline │ │ │ │ ├── common │ │ │ │ ├── MetricImporterUtils.java │ │ │ │ ├── MetricUtils.java │ │ │ │ └── SelfReportObserver.java │ │ │ │ ├── exporter │ │ │ │ ├── DynamicExportChainProvider.java │ │ │ │ ├── ExportChainFactory.java │ │ │ │ ├── MetricsExportChainManager.java │ │ │ │ └── filter │ │ │ │ │ ├── ExportFilters.java │ │ │ │ │ ├── MetricsTagFilter.java │ │ │ │ │ └── parser │ │ │ │ │ └── TagsFilterParser.java │ │ │ │ ├── filter │ │ │ │ └── builtin │ │ │ │ │ ├── post │ │ │ │ │ └── CommonMetricFilter.java │ │ │ │ │ └── pre │ │ │ │ │ ├── DebugPreFilter.java │ │ │ │ │ ├── ImporterStatsFilter.java │ │ │ │ │ ├── MetricDigestPreFilter.java │ │ │ │ │ ├── RateLimitPreFilter.java │ │ │ │ │ └── TokenPreFilter.java │ │ │ │ ├── importer │ │ │ │ ├── AbstractWebfluxImporter.java │ │ │ │ ├── FakeMetricsImporterProcessor.java │ │ │ │ ├── FakePrometheusMetricsImporter.java │ │ │ │ └── FakeStandardMetricsImporter.java │ │ │ │ ├── model │ │ │ │ ├── Metric.java │ │ │ │ ├── RawMetric.java │ │ │ │ ├── RawMetricHead.java │ │ │ │ └── SourceType.java │ │ │ │ ├── queue │ │ │ │ └── MetricsPersistQueueProcessor.java │ │ │ │ ├── reader │ │ │ │ └── ReaderManager.java │ │ │ │ └── scrape │ │ │ │ └── ScrapeImporter.java │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── gateway │ │ │ └── metrics │ │ │ └── pipeline │ │ │ ├── common │ │ │ └── MetricImporterUtilsTest.java │ │ │ └── queue │ │ │ └── MetricsPersistQueueProcessorTest.java │ └── starter │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── gateway │ │ │ └── metrics │ │ │ └── starter │ │ │ ├── DefaultReaderManager.java │ │ │ ├── ExportManageServerRunner.java │ │ │ ├── MetricPipelineConfiguration.java │ │ │ ├── MetricRunner.java │ │ │ ├── PostFilterManager.java │ │ │ ├── SelfMetricsStarter.java │ │ │ └── spring │ │ │ └── bean │ │ │ └── config │ │ │ └── SelfMetricConfiguration.java │ │ └── resources │ │ └── META-INF │ │ └── spring.factories └── pom.xml ├── pom.xml ├── samples └── metrics │ └── client │ ├── lookout-client-samples-boot │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── client │ │ │ └── samples │ │ │ └── Stater.java │ │ └── resources │ │ └── application.properties │ ├── lookout-client-samples-dropwizard-boot │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── client │ │ │ └── samples │ │ │ └── Stater.java │ │ └── resources │ │ └── application.properties │ ├── lookout-client-samples-java │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── lookout │ │ └── client │ │ └── samples │ │ ├── DefaultLookoutClientDemo.java │ │ └── SimpleLookoutClientDemo.java │ ├── lookout-client-samples-prometheus │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── client │ │ │ └── samples │ │ │ └── Stater.java │ │ └── resources │ │ └── application.properties │ └── lookout-samples-prom-push │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── alipay │ └── sofa │ └── lookout │ └── samples │ └── PushDemo.java └── server ├── README.md ├── common ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── lookout │ │ └── server │ │ └── common │ │ ├── AccessToken.java │ │ └── es │ │ └── operation │ │ ├── ESDataType.java │ │ ├── ESOperator.java │ │ └── ESOperatorBuilder.java │ └── test │ └── java │ └── com │ └── alipay │ └── sofa │ └── lookout │ └── server │ └── common │ └── es │ └── operation │ └── ESOperatorTest.java ├── metrics ├── interfaces │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── lookout │ │ └── server │ │ └── interfaces │ │ ├── IndexController.java │ │ ├── PromExtQueryController.java │ │ ├── PromQueryController.java │ │ ├── common │ │ ├── NetworkUtil.java │ │ ├── Preconditions.java │ │ ├── QueryExpressionUtil.java │ │ └── TimestampUtil.java │ │ ├── exception │ │ ├── PromClientException.java │ │ ├── PromExceptionHandler.java │ │ ├── PromQueryException.java │ │ └── PromServerException.java │ │ └── model │ │ ├── ErrorData.java │ │ ├── MatrixResult.java │ │ ├── QueryResult.java │ │ ├── ScalarResult.java │ │ ├── SlowLog.java │ │ ├── ValueData.java │ │ └── VectorResult.java ├── promql │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── server │ │ │ └── prom │ │ │ ├── common │ │ │ ├── DebugLog.java │ │ │ ├── NativeQueryInfo.java │ │ │ └── QueryConstants.java │ │ │ ├── exception │ │ │ ├── QLParseException.java │ │ │ └── TooManyPointsException.java │ │ │ ├── labels │ │ │ ├── Label.java │ │ │ ├── Labels.java │ │ │ ├── MatchType.java │ │ │ └── Matcher.java │ │ │ ├── ql │ │ │ ├── ast │ │ │ │ ├── AggregateExpr.java │ │ │ │ ├── Ast.java │ │ │ │ ├── BinaryExpr.java │ │ │ │ ├── Call.java │ │ │ │ ├── Card.java │ │ │ │ ├── EvalStmt.java │ │ │ │ ├── Expr.java │ │ │ │ ├── ExprContext.java │ │ │ │ ├── Expressions.java │ │ │ │ ├── MatrixSelector.java │ │ │ │ ├── Node.java │ │ │ │ ├── NodeInspector.java │ │ │ │ ├── NumberLiteral.java │ │ │ │ ├── ParenExpr.java │ │ │ │ ├── RecordStmt.java │ │ │ │ ├── Statement.java │ │ │ │ ├── Statements.java │ │ │ │ ├── StringLiteral.java │ │ │ │ ├── UnaryExpr.java │ │ │ │ ├── VectorMatching.java │ │ │ │ ├── VectorSelector.java │ │ │ │ └── Visitor.java │ │ │ ├── engine │ │ │ │ ├── Analysis.java │ │ │ │ ├── EngineOptions.java │ │ │ │ ├── Evaluator.java │ │ │ │ ├── GroupedAggregation.java │ │ │ │ ├── MetricSignCalculator.java │ │ │ │ ├── PromQLEngine.java │ │ │ │ ├── Query.java │ │ │ │ ├── QueryAnalyzer.java │ │ │ │ ├── QueryHints.java │ │ │ │ └── Result.java │ │ │ ├── func │ │ │ │ ├── AggrFn.java │ │ │ │ ├── FuncCallFn.java │ │ │ │ ├── Function.java │ │ │ │ └── support │ │ │ │ │ ├── Bucket.java │ │ │ │ │ ├── PromBucket.java │ │ │ │ │ └── Quantile.java │ │ │ ├── lex │ │ │ │ ├── Item.java │ │ │ │ ├── ItemType.java │ │ │ │ ├── ItemTypeSupport.java │ │ │ │ ├── Lexer.java │ │ │ │ └── StateFn.java │ │ │ ├── parse │ │ │ │ ├── ParseErr.java │ │ │ │ ├── Parser.java │ │ │ │ └── SequenceValue.java │ │ │ └── value │ │ │ │ ├── Matrix.java │ │ │ │ ├── Scalar.java │ │ │ │ ├── Series.java │ │ │ │ ├── StringValue.java │ │ │ │ ├── Value.java │ │ │ │ ├── ValueType.java │ │ │ │ └── Vector.java │ │ │ ├── storage │ │ │ ├── Storage.java │ │ │ └── query │ │ │ │ ├── AbstractQueryStmt.java │ │ │ │ ├── AggregateStatement.java │ │ │ │ ├── LabelValuesStatement.java │ │ │ │ ├── MetadataStatement.java │ │ │ │ ├── Querier.java │ │ │ │ └── QueryStatement.java │ │ │ └── util │ │ │ └── NoopUtils.java │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── server │ │ │ └── prom │ │ │ ├── TestBase.java │ │ │ ├── labels │ │ │ ├── LabelTest.java │ │ │ ├── LabelsTest.java │ │ │ └── MatcherTest.java │ │ │ └── ql │ │ │ ├── engine │ │ │ └── PromQLEngineTest.java │ │ │ ├── func │ │ │ └── FunctionTest.java │ │ │ ├── lex │ │ │ └── LexerTest.java │ │ │ ├── parse │ │ │ └── ParserTest.java │ │ │ └── value │ │ │ └── SeriesTest.java │ │ └── resources │ │ └── testdata │ │ ├── avg_over_time.test │ │ ├── max_over_time.test │ │ ├── min_over_time.test │ │ ├── range_query.test │ │ └── sum_over_time.test ├── starter │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── sofa │ │ │ │ └── lookout │ │ │ │ └── server │ │ │ │ └── starter │ │ │ │ ├── ServerAutoConfiguration.java │ │ │ │ └── ServerProperties.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── spring.factories │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── server │ │ │ └── storage │ │ │ └── ext │ │ │ └── es │ │ │ └── ElasticSearchStorageTest.java │ │ └── resources │ │ └── config │ │ └── application.properties ├── storage-ext-es │ ├── es-config │ │ └── mappings │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── lookout │ │ │ └── server │ │ │ └── storage │ │ │ └── ext │ │ │ └── es │ │ │ ├── ElasticSearchAggregateStmt.java │ │ │ ├── ElasticSearchLabelNamesStmt.java │ │ │ ├── ElasticSearchLabelValuesStmt.java │ │ │ ├── ElasticSearchQueryStmt.java │ │ │ ├── ElasticSearchStorage.java │ │ │ ├── QueryBuilder.java │ │ │ ├── operation │ │ │ └── ESMetricsDataOperator.java │ │ │ └── spring │ │ │ └── bean │ │ │ └── config │ │ │ └── ElasticSearchServerConfig.java │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── lookout │ │ └── server │ │ └── storage │ │ └── ext │ │ └── es │ │ └── QueryBuilderTest.java └── web-ui │ ├── pom.xml │ └── src │ └── main │ └── resources │ └── public │ ├── index.3f0735e8.css │ ├── index.6c3e3d33.js │ └── index.html ├── pom.xml └── server-test ├── pom.xml └── src └── main └── java └── com └── alipay └── sofa └── lookout └── server └── test └── ServerTestBase.java /.dockerignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .git/ 3 | target/ 4 | logs/ 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Ask_Question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Ask Question 3 | about: Ask a question about usage or feature 4 | 5 | --- 6 | 7 | ### Your question 8 | 9 | describe your question clearly 10 | 11 | ### Your scenes 12 | 13 | describe your use scenes (why need this feature) 14 | 15 | ### Your advice 16 | 17 | describe the advice or solution you'd like 18 | 19 | ### Environment 20 | 21 | - SOFALookout version: 22 | - JVM version (e.g. `java -version`): 23 | - OS version (e.g. `uname -a`): 24 | - Maven version: 25 | - IDE version: 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug_Report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | ### Describe the bug 8 | 9 | A clear and concise description of what the bug is. 10 | 11 | ### Expected behavior 12 | 13 | ### Actual behavior 14 | 15 | ### Steps to reproduce 16 | 17 | ### Minimal yet complete reproducer code (or GitHub URL to code) 18 | 19 | ### Environment 20 | 21 | - SOFALookout version: 22 | - JVM version (e.g. `java -version`): 23 | - OS version (e.g. `uname -a`): 24 | - Maven version: 25 | - IDE version: 26 | 27 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Motivation: 2 | 3 | Explain the context, and why you're making that change. 4 | To make others understand what is the problem you're trying to solve. 5 | 6 | ### Modification: 7 | 8 | Describe the idea and modifications you've done. 9 | 10 | ### Result: 11 | 12 | Fixes #. 13 | 14 | If there is no issue then describe the changes introduced by this PR. 15 | 16 | -------------------------------------------------------------------------------- /.github/workflows/cloud_code_scan.yml: -------------------------------------------------------------------------------- 1 | name: Alipay Cloud Devops Codescan 2 | on: 3 | pull_request_target: 4 | jobs: 5 | stc: # Code security scanning 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: codeScan 9 | uses: layotto/alipay-cloud-devops-codescan@main 10 | with: 11 | parent_uid: ${{ secrets.ALI_PID }} 12 | private_key: ${{ secrets.ALI_PK }} 13 | scan_type: stc 14 | sca: # Open source compliance scanning 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: codeScan 18 | uses: layotto/alipay-cloud-devops-codescan@main 19 | with: 20 | parent_uid: ${{ secrets.ALI_PID }} 21 | private_key: ${{ secrets.ALI_PK }} 22 | scan_type: sca 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | bin 3 | bak 4 | .pmd 5 | .project 6 | .settings 7 | .classpath 8 | .idea.xml 9 | .idea 10 | *.class 11 | *.bak 12 | *.iml 13 | *.ipr 14 | *.iws 15 | bak 16 | null/ 17 | tree.log 18 | tmp/ 19 | *.log 20 | *.DS_Store 21 | pom.xml.versionsBackup 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | 4 | jdk: 5 | - openjdk8 6 | 7 | install: 8 | - mvn clean install -Dmaven.javadoc.skip=true -B -V 9 | 10 | script: 11 | - sh ./check_format.sh 12 | 13 | after_success: 14 | - mvn clean test cobertura:cobertura org.eluder.coveralls:coveralls-maven-plugin:report 15 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.6.1-jdk-8 2 | LABEL MAINTAINER kevin.luy@antfin.com,xiangfeng.xzc@antfin.com 3 | 4 | ENV deploy_path /home/admin/deploy 5 | 6 | 7 | COPY . $deploy_path/source 8 | 9 | 10 | RUN mkdir -p /root/.m2 && \ 11 | cd $deploy_path/source && \ 12 | mv docker/settings-aliyun.xml /root/.m2/settings.xml && \ 13 | mv docker/entrypoint.sh $deploy_path/entrypoint.sh && \ 14 | chmod a+x $deploy_path/entrypoint.sh && \ 15 | mvn clean package -Psofaark -B -e -T 1C -Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8 -Dmaven.test.skip=true -am -pl boot/all-in-one-bootstrap && \ 16 | mv $deploy_path/source/boot/all-in-one-bootstrap/target/allinone-executable.jar $deploy_path/app.jar && \ 17 | cd ~ && \ 18 | rm -rf /root/.m2 $deploy_path/source && \ 19 | useradd admin && \ 20 | chown -R admin:admin /home/admin 21 | 22 | EXPOSE 6200 7200 9090 23 | 24 | VOLUME /home/admin/logs /home/admin/lookout_gateway_queue_cache 25 | 26 | USER admin 27 | WORKDIR /home/admin 28 | 29 | ENTRYPOINT ["/home/admin/deploy/entrypoint.sh"] 30 | -------------------------------------------------------------------------------- /HEADER: -------------------------------------------------------------------------------- 1 | Licensed to the Apache Software Foundation (ASF) under one or more 2 | contributor license agreements. See the NOTICE file distributed with 3 | this work for additional information regarding copyright ownership. 4 | The ASF licenses this file to You under the Apache License, Version 2.0 5 | (the "License"); you may not use this file except in compliance with 6 | the License. You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | -------------------------------------------------------------------------------- /boot/all-in-one-bootstrap/README.md: -------------------------------------------------------------------------------- 1 | # 运行方式 # 2 | 运行之前需要先启动ES实例 3 | > docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:5.6 4 | 5 | 先打包 6 | ``` 7 | ./boot/all-in-one-bootstrap/build.sh 8 | ``` 9 | 10 | 在fat-jar同目录下创建一个`abc.properties`配置文件, 用于存放存放配置文件 11 | ```properties 12 | gateway.metrics.exporter.es.host=localhost 13 | gateway.metrics.exporter.es.port=9200 14 | metrics-server.spring.data.jest.uri=http://localhost:9200 15 | ``` 16 | 17 | 执行fat-jar包 18 | ``` 19 | java -Dcom.alipay.sofa.ark.master.biz=lookoutall \ 20 | -Dlookoutall.config-file=abc.properties \ 21 | -jar allineone-executable.jar 22 | ``` 23 | 24 | > 注意 -Dcom.alipay.sofa.ark.master.biz=lookoutall 是必须的, 用于设置sofa-ark的master biz. 25 | > lookoutall.config-file 目前只能引用文件系统上的properties文件(没有像spring-boot支持那么丰富), 配置项必须以应用名开头, 从而提供隔离能力. 26 | -------------------------------------------------------------------------------- /boot/all-in-one-bootstrap/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | current_dir=$( dirname $0) 4 | cd $current_dir/../.. 5 | mvn clean install -T 1C -Psofaark -P!single-bootstrap -Dmaven.test.skip=true -am -pl boot/all-in-one-bootstrap 6 | -------------------------------------------------------------------------------- /boot/all-in-one-bootstrap/src/main/resources/README.md: -------------------------------------------------------------------------------- 1 | # 说明 # 2 | 各个ark包(gateway和server)的配置文件可以放在这里, 避免为了修改配置而重新对他们打包(根据目前的打包方式来讲, 现在这个没有太大的意义) 3 | -------------------------------------------------------------------------------- /boot/all-in-one-bootstrap/src/main/resources/app-configs/lookoutgateway/application-dev.properties: -------------------------------------------------------------------------------- 1 | # 这里放profile=dev时生效的配置 2 | # 跟 spring boot 里的概念是一样的 3 | -------------------------------------------------------------------------------- /boot/all-in-one-bootstrap/src/main/resources/app-configs/lookoutgateway/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sofastack/sofa-lookout/dc68c46b0495fa50fd23c254ab9ac8ad0116930c/boot/all-in-one-bootstrap/src/main/resources/app-configs/lookoutgateway/application.properties -------------------------------------------------------------------------------- /boot/all-in-one-bootstrap/src/main/resources/app-configs/lookoutserver/application-dev.properties: -------------------------------------------------------------------------------- 1 | # 这里放profile=dev时生效的配置 2 | # 跟 spring boot 里的概念是一样的 3 | -------------------------------------------------------------------------------- /boot/all-in-one-bootstrap/src/main/resources/app-configs/lookoutserver/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sofastack/sofa-lookout/dc68c46b0495fa50fd23c254ab9ac8ad0116930c/boot/all-in-one-bootstrap/src/main/resources/app-configs/lookoutserver/application.properties -------------------------------------------------------------------------------- /boot/gateway-bootstrap/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=gateway 2 | metrics.exporters=es 3 | metrics.importers=standard,prometheus,metricbeat,opentsdb 4 | 5 | #metrics.exporter.es.index=metrics 6 | metrics.exporter.es.host=localhost 7 | metrics.exporter.es.port=9200 8 | 9 | metrics.exporter.es.operation.auto=true 10 | server.port=7200 -------------------------------------------------------------------------------- /boot/metrics-server-bootstrap/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=metrics-server 2 | metrics.server.storage=es 3 | metrics.server.es.index=metrics 4 | #metrics.server.es.operation.auto=false 5 | #metrics.server.es.operation.rollover.maxAge=1d 6 | #metrics.server.es.operation.rollover.maxDocs=10000 7 | #spring.data.jest.uri=http://lookout:dkZpMNJF@search.alipay.com:9999 8 | spring.data.jest.uri=http://localhost:9200 9 | server.port=9090 -------------------------------------------------------------------------------- /boot/sofa-ark-support/src/main/java/com/alipay/sofa/lookout/ark/support/BootUtils.java: -------------------------------------------------------------------------------- 1 | package com.alipay.sofa.lookout.ark.support; 2 | 3 | import com.alipay.sofa.ark.support.startup.SofaArkBootstrap; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * @author xiangfeng.xzc 10 | * @date 2019/1/2 11 | */ 12 | public final class BootUtils { 13 | public static final String SOFA_ARK_MARK = "com.alipay.sofa.lookout.all.boot.LookoutAllBootstrap"; 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(BootUtils.class); 16 | 17 | private BootUtils() {} 18 | 19 | private static final String BIZ_CLASSLOADER = "com.alipay.sofa.ark.container.service.classloader.BizClassLoader"; 20 | 21 | public static boolean isSofaArkStarted() { 22 | Class bizClassloader = SofaArkBootstrap.class.getClassLoader().getClass(); 23 | return BIZ_CLASSLOADER.equals(bizClassloader.getCanonicalName()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /check_format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BASEDIR=$(dirname $0) 4 | 5 | cd ${BASEDIR} 6 | 7 | # make sure git has no un commit files 8 | if [ -n "$(git status --untracked-files=no --porcelain)" ]; then 9 | echo "Please commit your change before run this shell, un commit files:" 10 | git status --untracked-files=no --porcelain 11 | exit -1 12 | fi 13 | -------------------------------------------------------------------------------- /client/HEADER: -------------------------------------------------------------------------------- 1 | Licensed to the Apache Software Foundation (ASF) under one or more 2 | contributor license agreements. See the NOTICE file distributed with 3 | this work for additional information regarding copyright ownership. 4 | The ASF licenses this file to You under the Apache License, Version 2.0 5 | (the "License"); you may not use this file except in compliance with 6 | the License. You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | # SOFALookout Client 2 | 3 | [English Document](./README-EN.md) 4 | 5 | SOFALookout Client 是一个 Java 的开发工具库,可以为您的工程提供关键指标的度量服务。相较于传统的层级结构的 metrics,通过使用 SOFALookout client 的 API 可以为您提供多维度的 metrics。该客户端遵循 metrics 2.0 标准。 6 | 7 | ## 1. 编译 8 | 9 | SOFALookout Client 项目支持 Maven 3.2.5+,JDK 6+ 进行编译。 10 | 11 | ## 2. API 埋点需知 12 | 13 | lookout-api 支持被单独依赖和使用,方便植入您的项目代码,收集需要的 metrics,更多信息参考 [官方文档](http://www.sofastack.tech/sofa-lookout/docs/Home)。 14 | 15 | ## 3. 扩展能力 16 | 17 | lookout 客户端提供了 SPI 机制(只需要实现 `com.alipay.lookout.spi.MetricsImporter` 接口),支持可以扩展一些公共的Metrics收集模块,比如默认提供的:jvm(lookout-ext-jvm)、os(lookout-ext-os)。 18 | 19 | ## 4.Metrics的注册表 20 | 21 | - lookout-reg-prometheus 模块可以提供简单的 metrics 的查询服务,作为 lookout 的 exporter 被 prometheus 抓取; 22 | - lookout-reg-server 模块可以定时向 lookout server 上报 metrics 数据; 23 | - lookout-reg-dropwizard 模块可以降维映射为 dropwizard 注册表上; 24 | - lookout-api 模块自带 NoopRegistry 功能,如果当前运行环境未提供具体的 Registry 可用(比如,无客户端依赖)。 25 | 26 | ## 5.模块间依赖 27 | 28 | ``` 29 | +--------+ 30 | | API | 31 | +----^---+ 32 | | 33 | +----+---+ 34 | | COMMON | 35 | +----^---+ 36 | | 37 | +------+ +----+---+ 38 | | EXTS +-----> CORE | 39 | +--^---+ +----^---+ 40 | | | 41 | | +----+---+ 42 | | | REGS | 43 | | +----^---+ 44 | | | 45 | | +----+---+ 46 | +---------+ CLIENT | 47 | +--------+ 48 | ``` 49 | 50 | ## 6.如何使用 51 | 52 | 参考 [官方文档](http://www.sofastack.tech/sofa-lookout/docs/Home)的快速开始和用户手册。 53 | -------------------------------------------------------------------------------- /client/README_EN.md: -------------------------------------------------------------------------------- 1 | # Lookout Client Project 2 | 3 | Lookout client is a java library which helps to expose metrics of your project. In contrast to traditional 4 | hierarchical metrics, lookout client can provide multi-dimensional metrics with its API. It follows the 5 | [metrics2.0](http://metrics20.org/) standard. 6 | 7 | # Features 8 | - support for Java 6+ 9 | - [lookout-api](./lookout-api) can work alone, you can use it to collect metrics of your java project 10 | - with [lookout-reg-prometheus](./lookout-reg-web) dependency, it will start a nested http server, and provides metrics query services in your project. 11 | Prometheus can scrape metrics from this service. 12 | - with [lookout-sofa-boot-starter](./lookout-sofa-boot-starter) dependency, this client can work on a spring boot project -------------------------------------------------------------------------------- /client/change_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | shopt -s expand_aliases 3 | if [ ! -n "$1" ] ;then 4 | echo "Please enter a version" 5 | exit 1 6 | else 7 | echo "The version is $1 !" 8 | fi 9 | if [ `uname` == "Darwin" ] 10 | then 11 | echo "This is OS X" 12 | alias sed='sed -i ""' 13 | else 14 | echo "This is Linux" 15 | alias sed='sed -i' 16 | fi 17 | echo "Change version in root pom.xml ===>" 18 | sed "/.*<\/version>/$1<\/version>/" pom.xml 19 | 20 | echo "Change version in subproject pom ===>" 21 | for filename in `find . -maxdepth 2 -mindepth 2 -name "pom.xml"` 22 | do 23 | echo "Deal with $filename" 24 | sed "//,/<\/parent>/ s/.*<\/version>/$1<\/version>/" $filename 25 | done 26 | -------------------------------------------------------------------------------- /client/lookout-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.alipay.sofa.lookout 7 | lookout-client-parent 8 | 1.6.1 9 | ../pom.xml 10 | 11 | 12 | com.alipay.sofa.lookout 13 | lookout-api 14 | client-api 15 | jar 16 | 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | com.google.guava 25 | guava 26 | test 27 | 28 | 29 | junit 30 | junit 31 | test 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/BucketCounter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api; 18 | 19 | /** 20 | * 21 | * @author zhangzhuo 22 | * @version $Id: BucketCounter.java, v 0.1 2018年09月11日 下午1:37 zhangzhuo Exp $ 23 | */ 24 | public interface BucketCounter extends Metric { 25 | 26 | /** 27 | * enable recording bucket counts 28 | * @param buckets 29 | */ 30 | void buckets(long[] buckets); 31 | 32 | } -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/Gauge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api; 18 | 19 | /** 20 | * 即时的数据观察值,适用于度量的对象是黑盒的状态采样。 21 | * 22 | * Created by kevin.luy@alipay.com on 2017/2/14. 23 | */ 24 | public interface Gauge { 25 | 26 | /** 27 | * get an instant value of a target 28 | * @return an instant value 29 | */ 30 | T value(); 31 | } 32 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/Metric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api; 18 | 19 | /** 20 | * metric with identification 21 | * Created by kevin.luy@alipay.com on 2017/2/14. 22 | */ 23 | public interface Metric { 24 | 25 | /** 26 | * Identifier used to lookup this metric in the registry. 27 | * 28 | * @return id 29 | */ 30 | Id id(); 31 | 32 | /** 33 | * Get the set of measurements 34 | * 35 | * @return indicator a set of measurements 36 | */ 37 | Indicator measure(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/NoopGauge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api; 18 | 19 | /** 20 | * Gauge implementation for the no-op registry. 21 | * Created by kevin.luy@alipay.com on 2017/2/14. 22 | */ 23 | enum NoopGauge implements Gauge, Metric { 24 | /** 25 | * Singleton instance. 26 | */ 27 | INSTANCE; 28 | 29 | @Override 30 | public Id id() { 31 | return NoopId.INSTANCE; 32 | } 33 | 34 | @Override 35 | public Indicator measure() { 36 | return null; 37 | } 38 | 39 | @Override 40 | public Double value() { 41 | return Double.NaN; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/NoopInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api; 18 | 19 | import com.alipay.lookout.api.info.Info; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2017/3/9. 23 | */ 24 | enum NoopInfo implements Info, Metric { 25 | INSTANCE; 26 | 27 | @Override 28 | public Id id() { 29 | return NoopId.INSTANCE; 30 | } 31 | 32 | @Override 33 | public Object value() { 34 | return null; 35 | } 36 | 37 | @Override 38 | public Indicator measure() { 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/PRIORITY.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api; 18 | 19 | /** 20 | * metric priority tag suggest auto poll interval 21 | *

22 | * Created by kevin.luy@alipay.com on 2017/2/23. 23 | */ 24 | public enum PRIORITY { 25 | //Immediate 26 | //Urgent, 27 | HIGH, //5S 28 | NORMAL, //30S 29 | LOW //1min 30 | } 31 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/ResettableStep.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api; 18 | 19 | /** 20 | * 暴露一个接口用于修改 step 21 | * 22 | * @author xiangfeng.xzc 23 | * 2018/7/26 24 | */ 25 | public interface ResettableStep { 26 | /** 27 | * 设置新的step 28 | * 29 | * @param step 新的步长, 必须大于 0 30 | */ 31 | void setStep(long step); 32 | } 33 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/Tag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api; 18 | 19 | /** 20 | * a dimension of a metric 21 | * 22 | * Created by kevin.luy@alipay.com on 2017/1/26. 23 | */ 24 | public interface Tag { 25 | /** 26 | * the key of a tag 27 | * @return key 28 | */ 29 | String key(); 30 | 31 | /** 32 | * the value fo a tag 33 | * @return value 34 | */ 35 | String value(); 36 | } 37 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/composite/MixinMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api.composite; 18 | 19 | import com.alipay.lookout.api.*; 20 | 21 | /** 22 | * MixinMetric is a mixin of basic metric types. 23 | * This metric can build a sub metric(for examples: Counter, Timer, DistributionSummary, Gauge) 24 | * Created by kevin.luy@alipay.com on 2017/2/14. 25 | */ 26 | public interface MixinMetric extends Metric { 27 | 28 | Counter counter(String componentCounterName); 29 | 30 | Timer timer(String componentTimerName); 31 | 32 | DistributionSummary distributionSummary(String componentDistributionSummaryName); 33 | 34 | Gauge gauge(String componentGaugeName, Gauge componentGauge); 35 | } 36 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/info/AutoPollFriendlyInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api.info; 18 | 19 | /** 20 | * 自动采集友好info 21 | * Created by kevin.luy@alipay.com on 2017/2/22. 22 | */ 23 | public interface AutoPollFriendlyInfo extends Info { 24 | /** 25 | * auto-poll(collect) suggest 26 | * (非数值类型metric 可能数据过大,或计算value()耗时,所以自身可以给出自动采集器的建议) 27 | * @return autoPollSuggestion 28 | */ 29 | AutoPollSuggestion autoPollSuggest(); 30 | 31 | /** 32 | * last modified timestamp; (Work with AutoPollSuggestion.POLL_WHEN_UPDATED) 33 | * 34 | * @return millisecond 35 | */ 36 | long lastModifiedTime(); 37 | } 38 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/api/info/Info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api.info; 18 | 19 | /** 20 | * Non - numerical metric 21 | *

22 | * Created by kevin.luy@alipay.com on 2017/2/22. 23 | */ 24 | public interface Info { 25 | /** 26 | * @return marshall as json,(String,Number directly output.); 27 | */ 28 | T value(); 29 | } 30 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/common/LookoutConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.common; 18 | 19 | import com.alipay.lookout.api.BasicTag; 20 | import com.alipay.lookout.api.Tag; 21 | 22 | /** 23 | * Created by kevin.luy@alipay.com on 2017/2/7. 24 | */ 25 | public interface LookoutConstants { 26 | 27 | String DOT = "."; 28 | 29 | String TAG_PRIORITY_KEY = "priority"; 30 | String TAG_GROUP_KEY = "group"; 31 | 32 | Tag HIGH_PRIORITY_TAG = new BasicTag(TAG_PRIORITY_KEY, "high"); 33 | 34 | Tag LOW_PRIORITY_TAG = new BasicTag(TAG_PRIORITY_KEY, "low"); 35 | 36 | //ant cloud shared middleware identification 37 | String INSTANCE_ID_NAME = "instance_id"; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/common/top/NoopTopGauger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.common.top; 18 | 19 | import com.alipay.lookout.api.Tag; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * Created by kevin.luy@alipay.com on 2017/3/31. 25 | */ 26 | enum NoopTopGauger implements TopGauger { 27 | INSTANCE; 28 | 29 | @Override 30 | public void record(long l, Tag... tags) { 31 | 32 | } 33 | 34 | @Override 35 | public void record(long l, Map tags) { 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/common/top/TopGauger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.common.top; 18 | 19 | import com.alipay.lookout.api.Tag; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * Created by kevin.luy@alipay.com on 2017/3/31. 25 | */ 26 | public interface TopGauger { 27 | void record(long l, Tag... tags); 28 | 29 | void record(long l, Map tags); 30 | } 31 | -------------------------------------------------------------------------------- /client/lookout-api/src/main/java/com/alipay/lookout/jdk8/Function.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.jdk8; 18 | 19 | /** 20 | * Created by kevin.luy@alipay.com on 2017/1/26. 21 | */ 22 | public interface Function { 23 | 24 | /** 25 | * Applies this function to the given argument. 26 | * 27 | * @param t the function argument 28 | * @return the function result 29 | */ 30 | R apply(T t); 31 | } 32 | -------------------------------------------------------------------------------- /client/lookout-api/src/test/java/com/alipay/lookout/api/IndicatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | /** 23 | * Created by kevin.luy@alipay.com on 2018/5/16. 24 | */ 25 | public class IndicatorTest { 26 | 27 | @Test 28 | public void testAddMeasument() { 29 | Indicator indicator = new Indicator(11l, NoopRegistry.INSTANCE.createId("name")); 30 | indicator.addMeasurement("k", 1); 31 | indicator.addMeasurement(new Measurement("K2", "V2")); 32 | Assert.assertEquals(2, indicator.measurements().size()); 33 | Assert.assertEquals(11l, indicator.getTimestamp()); 34 | Assert.assertTrue(indicator.id() == NoopId.INSTANCE); 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /client/lookout-api/src/test/java/com/alipay/lookout/api/UtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | /** 23 | * Created by kevin.luy@alipay.com on 2018/5/16. 24 | */ 25 | public class UtilsTest { 26 | 27 | @Test 28 | public void testGetTagValue() { 29 | 30 | Id id = new DefaultId("name").withTag("k1", "v1").withTag("k2", "v2"); 31 | 32 | Assert.assertEquals("v1", Utils.getTagValue(id, "k1")); 33 | Assert.assertNull(Utils.getTagValue(id, "k3")); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /client/lookout-api/src/test/java/com/alipay/lookout/api/info/AutoPollSuggestionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.api.info; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | import java.util.concurrent.TimeUnit; 23 | 24 | /** 25 | * Created by kevin.luy@alipay.com on 2018/5/16. 26 | */ 27 | public class AutoPollSuggestionTest { 28 | 29 | @Test 30 | public void testAutoPollSuggest() { 31 | AutoPollSuggestion autoPollSuggestion = new AutoPollSuggestion(3, TimeUnit.SECONDS); 32 | Assert.assertEquals(3000, autoPollSuggestion.intervalMills()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /client/lookout-client/src/main/java/com/alipay/lookout/client/LookoutClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.client; 18 | 19 | import com.alipay.lookout.api.Registry; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2017/6/1. 23 | */ 24 | public interface LookoutClient { 25 | 26 | /** 27 | * get the metrics registry 28 | * 29 | * @param registry impl 30 | * @return metric registry 31 | */ 32 | T getRegistry(); 33 | 34 | /** 35 | * Closes this resource, relinquishing any underlying resources. 36 | * 37 | * @throws Exception if this resource cannot be closed 38 | */ 39 | void close() throws Exception; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /client/lookout-common/src/test/java/com/alipay/lookout/common/utils/LookoutLoggerFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.common.utils; 18 | 19 | import com.alipay.lookout.common.log.LookoutLoggerFactory; 20 | import org.junit.Assert; 21 | import org.junit.Test; 22 | import org.slf4j.Logger; 23 | import org.slf4j.helpers.NOPLogger; 24 | 25 | /** 26 | * Created by kevin.luy@alipay.com on 2018/5/15. 27 | */ 28 | public class LookoutLoggerFactoryTest { 29 | 30 | @Test 31 | public void testLookoutLoggerFactory() { 32 | Logger logger = LookoutLoggerFactory.getLogger(LookoutLoggerFactoryTest.class); 33 | Assert.assertTrue(logger instanceof NOPLogger); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /client/lookout-common/src/test/java/com/alipay/lookout/common/utils/NetworkUtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.common.utils; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | /** 23 | * Created by kevin.luy@alipay.com on 2018/5/15. 24 | */ 25 | public class NetworkUtilTest { 26 | 27 | @Test 28 | public void testGetLocalAddress() { 29 | Assert.assertNotNull(NetworkUtil.getLocalAddress().getHostAddress()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /client/lookout-core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.alipay.sofa.lookout 8 | lookout-client-parent 9 | 1.6.1 10 | ../pom.xml 11 | 12 | 13 | com.alipay.sofa.lookout 14 | lookout-core 15 | client-core 16 | jar 17 | 18 | 19 | 20 | UTF-8 21 | 22 | 23 | 24 | 25 | com.alipay.sofa.lookout 26 | lookout-common 27 | 28 | 29 | com.alibaba 30 | fastjson 31 | 32 | 33 | org.apache.commons 34 | commons-configuration2 35 | 36 | 37 | 38 | junit 39 | junit 40 | test 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/core/MetricIterable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.core; 18 | 19 | import com.alipay.lookout.api.Metric; 20 | 21 | /** 22 | * @author zhangzhuo 23 | * @version $Id: MetricIterable.java, v 0.1 2018年09月17日 下午2:33 zhangzhuo Exp $ 24 | */ 25 | public interface MetricIterable extends Iterable { 26 | } -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/core/common/NewMetricFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.core.common; 18 | 19 | import com.alipay.lookout.api.Id; 20 | import com.alipay.lookout.api.Metric; 21 | import com.alipay.lookout.jdk8.Function; 22 | 23 | /** 24 | * Created by kevin.luy@alipay.com on 2017/3/9. 25 | */ 26 | public interface NewMetricFunction extends Function { 27 | R noopMetric(); 28 | } 29 | -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/core/config/MetricConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.core.config; 18 | 19 | import org.apache.commons.configuration2.Configuration; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2017/3/9. 23 | */ 24 | public interface MetricConfig extends Configuration { 25 | /** 26 | * protect memory usage from too many metrics registered cause by bugs 27 | */ 28 | int DEFAULT_MAX_METRICS_NUM = 3000; 29 | } 30 | -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/event/MetricRegistryListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.event; 18 | 19 | import com.alipay.lookout.api.Metric; 20 | 21 | /** 22 | * registry events listener 23 | * Created by kevin.luy@alipay.com on 2017/3/15. 24 | */ 25 | public interface MetricRegistryListener { 26 | 27 | /** 28 | * action on a event when a metric is removed from the registry 29 | * 30 | * @param metric a metric 31 | */ 32 | void onRemoved(Metric metric); 33 | 34 | /** 35 | * action on a event when a metric is added from the registry 36 | * 37 | * @param metric a metric 38 | */ 39 | void onAdded(Metric metric); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/report/AbstractPoller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.report; 18 | 19 | import com.alipay.lookout.api.MetricRegistry; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2017/2/13. 23 | */ 24 | public abstract class AbstractPoller implements MetricPoller { 25 | 26 | private final MetricRegistry registry; 27 | 28 | /** 29 | * 30 | * @param registry target 31 | */ 32 | public AbstractPoller(MetricRegistry registry) { 33 | this.registry = registry; 34 | } 35 | 36 | protected MetricRegistry registry() { 37 | return registry; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/report/MetricObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.report; 18 | 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | /** 23 | * Metric 度量数据的观察者 24 | * Created by kevin.luy@alipay.com on 2017/2/7. 25 | */ 26 | public interface MetricObserver { 27 | /** 28 | * 29 | * @param measures 每次更新推送的measures 30 | * @param metadata 附带的上下文元数据 31 | */ 32 | void update(List measures, Map metadata); 33 | 34 | boolean isEnable(); 35 | } 36 | -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/report/MetricPoller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.report; 18 | 19 | import com.alipay.lookout.spi.MetricFilter; 20 | 21 | /** 22 | * metrics 轮询器 23 | * Created by kevin.luy@alipay.com on 2017/2/13. 24 | */ 25 | public interface MetricPoller { 26 | 27 | /** 28 | * @param observer metric observer 29 | * @param metricFilter metric filter 30 | */ 31 | void poll(MetricObserver observer, MetricFilter metricFilter); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/spi/MetricFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.spi; 18 | 19 | import com.alipay.lookout.api.Metric; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2017/2/20. 23 | */ 24 | public interface MetricFilter { 25 | /** 26 | * 总是返回true的Filter 27 | */ 28 | MetricFilter TRUE = new MetricFilter() { 29 | @Override 30 | public boolean matches(Metric metric) { 31 | return true; 32 | } 33 | }; 34 | 35 | boolean matches(Metric metric); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/spi/MetricsImporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.spi; 18 | 19 | import com.alipay.lookout.api.Registry; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2017/2/16. 23 | */ 24 | public interface MetricsImporter { 25 | 26 | /** 27 | * register other metrics to registry 28 | * 29 | * @param registry 30 | */ 31 | void register(Registry registry); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/step/ScheduledService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.step; 18 | 19 | import java.util.concurrent.ScheduledFuture; 20 | import java.util.concurrent.TimeUnit; 21 | 22 | /** 23 | * Created by kevin.luy@alipay.com on 2018/4/3. 24 | */ 25 | public interface ScheduledService { 26 | 27 | ScheduledFuture scheduleAtFixedRateSkipIfLong(Runnable command, long initialDelay, 28 | long period, TimeUnit unit); 29 | 30 | void shutdown(); 31 | } 32 | -------------------------------------------------------------------------------- /client/lookout-core/src/main/java/com/alipay/lookout/step/StepValue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.lookout.step; 17 | 18 | /** 19 | * Base for {@link StepLong} and {@link StepDouble}. 20 | */ 21 | public interface StepValue { 22 | 23 | /** Get the value for the last completed interval as a rate per second. */ 24 | double pollAsRate(); 25 | 26 | /** Get the timestamp for the end of the last completed interval. */ 27 | long timestamp(); 28 | } 29 | -------------------------------------------------------------------------------- /client/lookout-core/src/test/java/com/alipay/lookout/spi/DefaultMetricsImporterLocatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.spi; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | /** 23 | * Created by kevin.luy@alipay.com on 2018/5/15. 24 | */ 25 | public class DefaultMetricsImporterLocatorTest { 26 | 27 | @Test 28 | public void testLocateImporters() { 29 | Assert.assertEquals(0, MetricsImporterLocator.locate().size()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /client/lookout-ext-jvm/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.alipay.sofa.lookout 8 | lookout-client-parent 9 | 1.6.1 10 | ../pom.xml 11 | 12 | 13 | lookout-ext-jvm 14 | client-ext-jvm 15 | jar 16 | 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | com.alipay.sofa.lookout 25 | lookout-core 26 | 27 | 28 | org.slf4j 29 | slf4j-api 30 | 31 | 32 | 33 | junit 34 | junit 35 | test 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /client/lookout-ext-jvm/src/main/java/com/alipay/lookout/jvm/LookoutIdNameConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.jvm; 18 | 19 | /** 20 | * LookoutIdNameConstants 21 | * 22 | * @author yangguanchao 23 | * @since 2018/01/27 24 | */ 25 | public class LookoutIdNameConstants { 26 | 27 | public static final String JVM_SYSTEM_PROP_NAME = "jvm.system.properties"; 28 | 29 | public static final String JVM_SYSTEM_ENV_NAME = "jvm.system.env"; 30 | } 31 | -------------------------------------------------------------------------------- /client/lookout-ext-jvm/src/main/resources/META-INF/services/com.alipay.lookout.spi.MetricsImporter: -------------------------------------------------------------------------------- 1 | com.alipay.lookout.jvm.JvmMemoryMetricsImporter 2 | com.alipay.lookout.jvm.JvmClassesMetricsImporter 3 | com.alipay.lookout.jvm.JvmGcMetricsImporter 4 | com.alipay.lookout.jvm.JvmThreadsMetricsImporter 5 | com.alipay.lookout.BasicMetricsImporter 6 | com.alipay.lookout.FileSystemSpaceMetricsImporter 7 | com.alipay.lookout.jvm.JvmSystemPropertiesInfoMetricImporter 8 | 9 | 10 | -------------------------------------------------------------------------------- /client/lookout-ext-os/src/main/resources/META-INF/services/com.alipay.lookout.spi.MetricsImporter: -------------------------------------------------------------------------------- 1 | com.alipay.lookout.os.linux.CpuUsageMetricsImporter 2 | com.alipay.lookout.os.linux.DiskUsageMetricsImporter 3 | com.alipay.lookout.os.linux.IOStatsMetricsImporter 4 | com.alipay.lookout.os.linux.NetTrafficMetricsImporter 5 | com.alipay.lookout.os.linux.SystemLoadMetricsImporter 6 | com.alipay.lookout.os.linux.MemoryStatsMetricsImporter 7 | 8 | -------------------------------------------------------------------------------- /client/lookout-ext-os/src/test/resources/proc_diskstats_1: -------------------------------------------------------------------------------- 1 | 1 0 ram0 0 0 0 0 0 0 0 0 0 0 0 2 | 1 1 ram1 0 0 0 0 0 0 0 0 0 0 0 3 | 1 2 ram2 0 0 0 0 0 0 0 0 0 0 0 4 | 1 3 ram3 0 0 0 0 0 0 0 0 0 0 0 5 | 1 4 ram4 0 0 0 0 0 0 0 0 0 0 0 6 | 1 5 ram5 0 0 0 0 0 0 0 0 0 0 0 7 | 1 6 ram6 0 0 0 0 0 0 0 0 0 0 0 8 | 1 7 ram7 0 0 0 0 0 0 0 0 0 0 0 9 | 1 8 ram8 0 0 0 0 0 0 0 0 0 0 0 10 | 1 9 ram9 0 0 0 0 0 0 0 0 0 0 0 11 | 1 10 ram10 0 0 0 0 0 0 0 0 0 0 0 12 | 1 11 ram11 0 0 0 0 0 0 0 0 0 0 0 13 | 1 12 ram12 0 0 0 0 0 0 0 0 0 0 0 14 | 1 13 ram13 0 0 0 0 0 0 0 0 0 0 0 15 | 1 14 ram14 0 0 0 0 0 0 0 0 0 0 0 16 | 1 15 ram15 0 0 0 0 0 0 0 0 0 0 0 17 | 8 0 sda 34684836 63262 4037630512 16138035 7706406749 20820501421 227546508158 746278605 0 373099196 759479488 18 | 8 1 sda1 823 9 4640 82 6404609 774695 14358620 21232885 0 7995697 21232106 19 | 8 2 sda2 50558 1848 3718858 14177 66868366 3867783 565951840 94326761 0 14251082 94325410 20 | 8 3 sda3 358 0 2864 51 2 0 2 362 0 215 413 21 | 8 4 sda4 3 0 12 1 0 0 0 0 0 1 1 22 | 8 5 sda5 34632920 61405 4033902746 16123715 7554370874 20815858943 226966197696 625840175 0 364713296 639065727 -------------------------------------------------------------------------------- /client/lookout-ext-os/src/test/resources/proc_diskstats_2: -------------------------------------------------------------------------------- 1 | 1 0 ram0 0 0 0 0 0 0 0 0 0 0 0 2 | 1 1 ram1 0 0 0 0 0 0 0 0 0 0 0 3 | 1 2 ram2 0 0 0 0 0 0 0 0 0 0 0 4 | 1 3 ram3 0 0 0 0 0 0 0 0 0 0 0 5 | 1 4 ram4 0 0 0 0 0 0 0 0 0 0 0 6 | 1 5 ram5 0 0 0 0 0 0 0 0 0 0 0 7 | 1 6 ram6 0 0 0 0 0 0 0 0 0 0 0 8 | 1 7 ram7 0 0 0 0 0 0 0 0 0 0 0 9 | 1 8 ram8 0 0 0 0 0 0 0 0 0 0 0 10 | 1 9 ram9 0 0 0 0 0 0 0 0 0 0 0 11 | 1 10 ram10 0 0 0 0 0 0 0 0 0 0 0 12 | 1 11 ram11 0 0 0 0 0 0 0 0 0 0 0 13 | 1 12 ram12 0 0 0 0 0 0 0 0 0 0 0 14 | 1 13 ram13 0 0 0 0 0 0 0 0 0 0 0 15 | 1 14 ram14 0 0 0 0 0 0 0 0 0 0 0 16 | 1 15 ram15 0 0 0 0 0 0 0 0 0 0 0 17 | 8 0 sda 34684842 63262 4037630616 16138037 7706429679 20820513162 227546785120 746290411 0 373099826 759491284 18 | 8 1 sda1 823 9 4640 82 6404612 774697 14358630 21232918 0 7995708 21232139 19 | 8 2 sda2 50558 1848 3718858 14177 66868405 3867784 565952160 94326870 0 14251093 94325519 20 | 8 3 sda3 358 0 2864 51 2 0 2 362 0 215 413 21 | 8 4 sda4 3 0 12 1 0 0 0 0 0 1 1 22 | 8 5 sda5 34632926 61405 4033902850 16123717 7554393715 20815870681 226966474328 625851836 0 364713923 639077378 -------------------------------------------------------------------------------- /client/lookout-ext-os/src/test/resources/proc_loadavg: -------------------------------------------------------------------------------- 1 | 2.40 2.28 2.38 3/1259 24252 -------------------------------------------------------------------------------- /client/lookout-ext-os/src/test/resources/proc_meminfo: -------------------------------------------------------------------------------- 1 | MemTotal: 4106756 kB 2 | MemFree: 51004 kB 3 | Buffers: 495632 kB 4 | Cached: 1691248 kB 5 | SwapCached: 0 kB 6 | Active: 2799008 kB 7 | Inactive: 1047516 kB 8 | Active(anon): 1393568 kB 9 | Inactive(anon): 286376 kB 10 | Active(file): 1405440 kB 11 | Inactive(file): 761140 kB 12 | Unevictable: 0 kB 13 | Mlocked: 0 kB 14 | SwapTotal: 2097144 kB 15 | SwapFree: 2097144 kB 16 | Dirty: 660 kB 17 | Writeback: 0 kB 18 | AnonPages: 1658804 kB 19 | Mapped: 73820 kB 20 | Shmem: 21180 kB 21 | Slab: 127452 kB 22 | SReclaimable: 99996 kB 23 | SUnreclaim: 27456 kB 24 | KernelStack: 5928 kB 25 | PageTables: 12424 kB 26 | NFS_Unstable: 0 kB 27 | Bounce: 0 kB 28 | WritebackTmp: 0 kB 29 | CommitLimit: 4150520 kB 30 | Committed_AS: 5889456 kB 31 | VmallocTotal: 34359738367 kB 32 | VmallocUsed: 17652 kB 33 | VmallocChunk: 34359717664 kB 34 | HardwareCorrupted: 0 kB 35 | AnonHugePages: 0 kB 36 | HugePages_Total: 0 37 | HugePages_Free: 0 38 | HugePages_Rsvd: 0 39 | HugePages_Surp: 0 40 | Hugepagesize: 2048 kB 41 | DirectMap4k: 4194304 kB 42 | DirectMap2M: 0 kB -------------------------------------------------------------------------------- /client/lookout-ext-os/src/test/resources/proc_mounts: -------------------------------------------------------------------------------- 1 | rootfs / rootfs rw 0 0 2 | /dev/sda5 / ext4 rw,relatime,barrier=1,nodelalloc,data=writeback,grpquota 0 0 3 | /lib /lib overlayfs rw,relatime,lowerdir=/lib,upperdir=/home/t4/LXC010110020235/store/lib 0 0 4 | /bin /bin overlayfs rw,relatime,lowerdir=/bin,upperdir=/home/t4/LXC010110020235/store/bin 0 0 5 | /usr /usr overlayfs rw,relatime,lowerdir=/usr,upperdir=/home/t4/LXC010110020235/store/usr 0 0 6 | /sbin /sbin overlayfs rw,relatime,lowerdir=/sbin,upperdir=/home/t4/LXC010110020235/store/sbin 0 0 7 | /dev/sda2 /sbin/reboot\040(deleted) ext4 rw,relatime,barrier=1,nodelalloc,data=ordered 0 0 8 | udev /dev devtmpfs rw,relatime,size=66124020k,nr_inodes=16531005,mode=755 0 0 9 | /dev/sda5 /dev/console ext4 rw,relatime,barrier=1,nodelalloc,data=writeback,grpquota 0 0 10 | devpts /dev/tty1 devpts rw,relatime,gid=5,mode=620,ptmxmode=000 0 0 11 | /sys /sys sysfs rw,relatime 0 0 12 | none /cgroup cgroup rw,relatime,kcounter,net_prio,perf_event,blkio,net_cls,freezer,devices,memory,cpuacct,cpu,ns,cpuset 0 0 13 | tmpfs /var/run tmpfs rw,relatime 0 0 14 | /lib64 /lib64 overlayfs rw,relatime,lowerdir=/lib64,upperdir=/home/t4/LXC010110020235/store/lib64 0 0 15 | devpts /dev/pts devpts rw,relatime,mode=600,ptmxmode=000 0 0 16 | devpts /dev/ptmx devpts rw,relatime,mode=600,ptmxmode=000 0 0 17 | proc /proc proc rw,relatime 0 0 18 | shm /dev/shm tmpfs rw,relatime 0 0 -------------------------------------------------------------------------------- /client/lookout-ext-os/src/test/resources/proc_net_dev: -------------------------------------------------------------------------------- 1 | Inter-| Receive | Transmit 2 | face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed 3 | lo:34700289753 147664365 0 0 0 0 0 0 34700289753 147664365 0 0 0 0 0 0 4 | eth0:4187067873934 8294848168 0 0 0 0 0 0 2691029093027 6803905965 0 0 0 0 0 0 5 | bond0:4187067873934 8294848168 0 0 0 0 0 0 2691029093027 6803905965 0 0 0 0 0 0 -------------------------------------------------------------------------------- /client/lookout-ext-os/src/test/resources/proc_stat: -------------------------------------------------------------------------------- 1 | cpu 2693535872 189893 2307803903 35070408424 8217498 259409 524760770 106733613 0 2 | cpu0 1227004415 41407 1028671342 7422458349 4880706 258483 473142785 46992352 0 3 | cpu1 493247075 55620 436676699 9208113409 1084477 294 18205658 20600578 0 4 | cpu2 491812624 51866 423869499 9215689824 1146846 350 17030467 19386694 0 5 | cpu3 481471756 40998 418586362 9224146840 1105468 281 16381859 19753987 0 6 | intr 14888129483 859880326 76823622 1029876 0 34594261 1097340557 126757572 1631821 0 48678803 3861660738 3461556128 1676718 0 47082519 2943417842 3246504864 1523005 0 46971052 869 5927 32934678 47076466 2288276870 61949606 1299320 2389527691 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 | ctxt 2579790093030 8 | btime 1379857468 9 | processes 450410619 10 | procs_running 2 11 | procs_blocked 0 12 | softirq 40731213476 0 353696558 2419464976 476646347 0 0 1 2991476190 472874444 3952283888 13 | per_cpu_ctxt 686591532899 633015403473 630286821948 629896334710 -------------------------------------------------------------------------------- /client/lookout-ext-os/src/test/resources/proc_uptime_1: -------------------------------------------------------------------------------- 1 | 31281445.68 890701588.19 -------------------------------------------------------------------------------- /client/lookout-ext-os/src/test/resources/proc_uptime_2: -------------------------------------------------------------------------------- 1 | 31281470.94 890702326.05 -------------------------------------------------------------------------------- /client/lookout-reg-dropwizard/src/main/java/com/alipay/lookout/dropwizard/metrics/DWMetricsGuage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.dropwizard.metrics; 18 | 19 | import com.alipay.lookout.api.Gauge; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2017/10/5. 23 | */ 24 | public class DWMetricsGuage implements com.codahale.metrics.Gauge { 25 | 26 | private final Gauge gauge; 27 | 28 | public DWMetricsGuage(Gauge dwGauge) { 29 | this.gauge = dwGauge; 30 | } 31 | 32 | @Override 33 | public T getValue() { 34 | return (T) gauge.value(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /client/lookout-reg-dropwizard/src/main/java/com/alipay/lookout/dropwizard/metrics/DwMetricWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.dropwizard.metrics; 18 | 19 | /** 20 | * Created by kevin.luy@alipay.com on 2017/1/26. 21 | */ 22 | public interface DwMetricWrapper { 23 | 24 | /** 25 | * @return dropwizard metric object which is delegated 26 | */ 27 | T getOriginDwMetric(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /client/lookout-reg-dropwizard/src/main/java/com/alipay/lookout/dropwizard/metrics/NameUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.dropwizard.metrics; 18 | 19 | import com.alipay.lookout.api.Id; 20 | import com.alipay.lookout.common.utils.CommonUtil; 21 | 22 | /** 23 | * http://metrics20.org/ 24 | *

25 | * Created by kevin.luy@alipay.com on 2017/1/26. 26 | */ 27 | final class NameUtils { 28 | 29 | private NameUtils() { 30 | } 31 | 32 | /** 33 | * Convert a dimensional metric id {@slink Id} to a hierarchical metric name. 34 | * 35 | * @param id a dimensional metric id 36 | * @return hierarchical metric name 37 | */ 38 | static String toMetricName(Id id) { 39 | return CommonUtil.toMetricName(id); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /client/lookout-reg-dropwizard/src/test/java/com/alipay/lookout/dropwizard/metrics/NameUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.dropwizard.metrics; 18 | 19 | import com.alipay.lookout.api.Clock; 20 | import com.alipay.lookout.core.DefaultRegistry; 21 | import org.junit.Assert; 22 | import org.junit.Test; 23 | 24 | /** 25 | * Created by kevin.luy@alipay.com on 2018/5/16. 26 | */ 27 | public class NameUtilsTest { 28 | 29 | @Test 30 | public void testMetricname() { 31 | String name = NameUtils.toMetricName(new DefaultRegistry(Clock.SYSTEM).createId("name") 32 | .withTag("k", "v")); 33 | System.out.println(name); 34 | Assert.assertEquals("name.k-v", name); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /client/lookout-reg-server/src/main/java/com/alipay/lookout/remote/report/MetricObserverMeasurementsFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.remote.report; 18 | 19 | import com.alipay.lookout.report.MetricObserver; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * Created by kevin.luy@alipay.com on 2017/8/30. 25 | */ 26 | public interface MetricObserverMeasurementsFilter { 27 | 28 | /** 29 | * 过滤出能处理的 measurements 30 | * 31 | * @param measurements 待筛选 measurements 32 | * @param metricObserver metric observer 33 | * @return 过滤后的结果 34 | */ 35 | List filter(List measurements, MetricObserver metricObserver); 36 | } 37 | -------------------------------------------------------------------------------- /client/lookout-reg-server/src/main/java/com/alipay/lookout/remote/report/poller/Listener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.remote.report.poller; 18 | 19 | /** 20 | * 用于监听 poller 激活 和 空闲 的事件 21 | * 22 | * @author xiangfeng.xzc 23 | * @since 2018/7/19 24 | */ 25 | public interface Listener { 26 | /** 27 | * 当poller激活时 28 | */ 29 | void onActive(); 30 | 31 | /** 32 | * 当poller空闲时 33 | */ 34 | void onIdle(); 35 | } 36 | -------------------------------------------------------------------------------- /client/lookout-reg-server/src/main/java/com/alipay/lookout/remote/report/support/http/ResultConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.remote.report.support.http; 18 | 19 | import org.apache.http.HttpEntity; 20 | 21 | /** 22 | * @author: kevin.luy@antfin.com 23 | * @create: 2019-05-20 11:46 24 | **/ 25 | public interface ResultConsumer { 26 | 27 | void consume(HttpEntity entity); 28 | } 29 | -------------------------------------------------------------------------------- /client/lookout-reg-server/src/test/java/com/alipay/lookout/remote/step/MockClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.remote.step; 18 | 19 | import com.alipay.lookout.api.ManualClock; 20 | 21 | @Deprecated 22 | public class MockClock extends ManualClock { 23 | } -------------------------------------------------------------------------------- /client/lookout-reg-server/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /client/lookout-sofa-boot-starter/src/main/java/com/alipay/lookout/starter/support/MetricConfigCustomizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.starter.support; 18 | 19 | import com.alipay.lookout.core.config.MetricConfig; 20 | 21 | /** 22 | * Callback interface that can be used to customize a metricConfig 23 | * Created by kevin.luy@alipay.com on 2018/9/5. 24 | */ 25 | public interface MetricConfigCustomizer { 26 | 27 | /** 28 | * customize a metricConfig 29 | * @param metricConfig metricConfig 30 | */ 31 | void customize(MetricConfig metricConfig); 32 | } 33 | -------------------------------------------------------------------------------- /client/lookout-sofa-boot-starter/src/main/java/com/alipay/lookout/starter/support/actuator/SpringBootActuatorRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.starter.support.actuator; 18 | 19 | import com.alipay.lookout.core.DefaultRegistry; 20 | import com.alipay.lookout.core.config.MetricConfig; 21 | 22 | /** 23 | * SpringBootActuatorRegistry 24 | * 25 | * @author yangguanchao 26 | * @since 2018/06/19 27 | */ 28 | public class SpringBootActuatorRegistry extends DefaultRegistry { 29 | 30 | public SpringBootActuatorRegistry(MetricConfig metricConfig) { 31 | super(metricConfig); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /client/lookout-sofa-boot-starter/src/main/java/com/alipay/lookout/starter/support/reg/MetricsRegistryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.starter.support.reg; 18 | 19 | import com.alipay.lookout.api.MetricRegistry; 20 | import com.alipay.lookout.core.config.MetricConfig; 21 | 22 | /** 23 | * Created by kevin.luy@alipay.com on 2018/5/10. 24 | */ 25 | public interface MetricsRegistryFactory { 26 | 27 | /** 28 | * get a registry instance from the factory 29 | * 30 | * @param metricConfig metricConfig 31 | * @return a registry 32 | */ 33 | T get(C metricConfig); 34 | } 35 | -------------------------------------------------------------------------------- /client/lookout-sofa-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | # Auto Configure 2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 3 | com.alipay.lookout.starter.autoConfiguration.LookoutAutoConfiguration,\ 4 | com.alipay.lookout.starter.configuration.MetricsActuatorAutoConfiguration 5 | 6 | 7 | # Initializers 8 | org.springframework.context.ApplicationContextInitializer=\ 9 | com.alipay.lookout.starter.support.LookoutApplicationContextInitializer 10 | -------------------------------------------------------------------------------- /client/lookout-sofa-boot-starter/src/test/java/com/alipay/lookout/starter/base/SpringBootWebApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.lookout.starter.base; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | 21 | /** 22 | * SpringBootWebApplication 23 | * 24 | * @author yangguanchao 25 | * @since 2018/06/15 26 | */ 27 | @org.springframework.boot.autoconfigure.SpringBootApplication 28 | public class SpringBootWebApplication { 29 | 30 | public static void main(String[] args) throws Exception { 31 | SpringApplication springApplication = new SpringApplication(SpringBootWebApplication.class); 32 | springApplication.run(args); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /client/lookout-sofa-boot-starter/src/test/resources/application-metrics.properties: -------------------------------------------------------------------------------- 1 | com.alipay.sofa.lookout.prometheusExporterServerPort=9696 2 | com.alipay.sofa.lookout.actuator-dropWizard-enabled=false 3 | 4 | -------------------------------------------------------------------------------- /client/lookout-sofa-boot-starter/src/test/resources/application-reader.properties: -------------------------------------------------------------------------------- 1 | com.alipay.sofa.lookout.prometheusExporterServerPort=9595 2 | com.alipay.sofa.lookout.actuator-dropWizard-enabled=false 3 | -------------------------------------------------------------------------------- /client/lookout-sofa-boot-starter/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=start-test 2 | com.alipay.sofa.lookout.enable=true 3 | com.alipay.sofa.lookout.agent-host-address 4 | com.alipay.sofa.lookout.max-metrics-num=1000 5 | com.alipay.sofa.lookout.prometheusExporterServerPort=9494 6 | com.alipay.sofa.lookout.exporter-idle=-2 7 | com.alipay.sofa.lookout.exporter-enable=true 8 | -------------------------------------------------------------------------------- /docker/README.md: -------------------------------------------------------------------------------- 1 | # 介绍 # 2 | 使用docker的方式来部署all-in-one-bootstrap. 3 | 4 | # 构建镜像 # 5 | 6 | 在项目根目录执行 7 | ```bash 8 | docker build -t lookout/allinone:1.0.0 . 9 | ``` 10 | 11 | > 为了在国内获得较好的构建速度, 构建时使用了aliyun的maven仓库. 12 | 13 | ## docker方式运行 ## 14 | 先运行ES 15 | ``` 16 | docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:5.6 17 | ``` 18 | 19 | 服务端默认会连接到`localhost:9200`的ES实例, 而我所用的开发机器是MacOS, 无法使用`--net=host`模式启动容器, 因此在容器内无法通过`localhost:9200`连接ES, 需要使用如下方式绕过去: 20 | 21 | 编辑一个配置文件, 比如foo.properties 22 | ```properties 23 | gateway.metrics.exporter.es.host=es 24 | metrics-server.spring.data.jest.uri=http://es:9200 25 | ``` 26 | 27 | 在foo.properties所在的目录下运行all-in-one镜像 28 | ```bash 29 | docker run -it \ 30 | --name allinone \ 31 | --link es:es \ 32 | -v $PWD/foo.properties:/home/admin/deploy/foo.properties \ 33 | -e JAVA_OPTS="-Dlookoutall.config-file=/home/admin/deploy/foo.properties" \ 34 | lookout/allinone:1.0.0 35 | ``` 36 | 37 | > 这里利用了docker的--link参数使得应用可以访问到ES实例 38 | > 这里做测试用, 所以不用-d参数在后台运行 39 | 40 | 41 | 如果在linux上启动则quickstart例子无需上述设置, 直接执行如下语句即可: 42 | ```bash 43 | docker run -it \ 44 | --name allinone \ 45 | lookout/allinone:1.0.0 46 | ``` 47 | -------------------------------------------------------------------------------- /docker/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # all in one entry point 4 | 5 | java_bin=java 6 | app_jar=/home/admin/deploy/app.jar 7 | 8 | # 构建 JVM 系统属性 9 | java_opts="-Dcom.alipay.sofa.ark.master.biz=lookoutall" 10 | java_opts="$java_opts $JAVA_OPTS" 11 | 12 | echo $java_bin -server $java_opts $app_jar 13 | $java_bin -server $java_opts -jar $app_jar 14 | -------------------------------------------------------------------------------- /docker/settings-aliyun.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | aliyun 9 | 10 | 11 | aliyun 12 | https://maven.aliyun.com/repository/central 13 | 14 | true 15 | never 16 | 17 | 18 | false 19 | 20 | 21 | 22 | 23 | 24 | aliyun 25 | https://maven.aliyun.com/repository/central 26 | 27 | true 28 | never 29 | 30 | 31 | false 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | aliyun 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/common/ConditionalOnMonitorComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.common; 18 | 19 | import org.springframework.context.annotation.Conditional; 20 | 21 | import java.lang.annotation.*; 22 | 23 | /** 24 | * @author kevin.luy@antfin.com 25 | * @create 2018-12-01 11:25 AM 26 | **/ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target({ ElementType.TYPE, ElementType.METHOD }) 29 | @Documented 30 | @Conditional(MonitorComponentConditional.class) 31 | public @interface ConditionalOnMonitorComponent { 32 | 33 | /** 34 | * @return monitor component name 35 | */ 36 | String value(); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/common/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.common; 18 | 19 | /** 20 | * @author: kevin.luy@antfin.com 21 | * @create: 2019-05-07 21:38 22 | **/ 23 | public interface Constants { 24 | String TOKEN_HEADER_NAME = "X-Lookout-Token"; 25 | String CLIENT_IP_HEADER_NAME = "Client-Ip"; 26 | String PRIORITY_HEADER_NAME = "pri"; 27 | String APP_HEADER_NAME = "app"; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/common/DataType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.common; 18 | 19 | /** 20 | * @author xiangfeng.xzc 21 | * @date 2018/11/26 22 | */ 23 | public enum DataType { 24 | METRIC, METRIC_INFO, LOG, TRACE, EVENT 25 | } 26 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/common/MonitorComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.common; 18 | 19 | /** 20 | * @author: kevin.luy@antfin.com 21 | * @create: 2019-01-04 20:04 22 | **/ 23 | public enum MonitorComponent { 24 | TRACE, METRIC, EVENT 25 | } 26 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/common/RefuseRequestService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.common; 18 | 19 | /** 20 | * 持有一个boolean值, 用于表示是否要拒绝请求 之前是将这个boolean值放在 Configuration 里, 感觉这样不好, 可以单独抽出一个类来做 21 | * 22 | * @author xiangfeng.xzc 23 | * @date 2018/11/22 24 | */ 25 | public interface RefuseRequestService { 26 | boolean isRefuseRequest(); 27 | 28 | void setRefuseRequest(boolean refuseRequest); 29 | } 30 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/common/impl/RefuseRequestServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.common.impl; 18 | 19 | import com.alipay.sofa.lookout.gateway.core.common.RefuseRequestService; 20 | 21 | /** 22 | * @author xiangfeng.xzc 23 | * @date 2018/11/22 24 | */ 25 | public class RefuseRequestServiceImpl implements RefuseRequestService { 26 | private volatile boolean refuseRequest; 27 | 28 | @Override 29 | public boolean isRefuseRequest() { 30 | return refuseRequest; 31 | } 32 | 33 | @Override 34 | public void setRefuseRequest(boolean refuseRequest) { 35 | this.refuseRequest = refuseRequest; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/exporter/ExportChainManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.exporter; 18 | 19 | import com.alipay.sofa.lookout.gateway.core.prototype.lifecycle.LifeCycle; 20 | 21 | /** 22 | * ExportChainManager 管理所有的(同一个数据模型的, 比如metrics)exporters 23 | * 24 | * @author xiangfeng.xzc 25 | * @date 2018/11/14 26 | */ 27 | public interface ExportChainManager extends LifeCycle { 28 | /** 29 | * 导出数据 30 | * 31 | * @param m 32 | */ 33 | void export(T m); 34 | } 35 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/exporter/buffer/Buffer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.exporter.buffer; 18 | 19 | import java.util.List; 20 | import java.util.function.Consumer; 21 | 22 | /** 23 | * TODO 可能需要配合定时器使用, 强制flush那些太久没有数据到来的buffer 24 | * 25 | * @author xiangfeng.xzc 26 | * @date 2018/11/13 27 | */ 28 | public interface Buffer { 29 | /** 30 | * 添加数据到buffer 31 | * 32 | * @param t 33 | */ 34 | void add(T t); 35 | 36 | /** 37 | * 强制刷新 38 | */ 39 | void flush(); 40 | 41 | void setConsumer(Consumer> consumer); 42 | } 43 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/exporter/chain/ExportChain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.exporter.chain; 18 | 19 | import com.alipay.sofa.lookout.gateway.core.prototype.exporter.Exporter; 20 | 21 | /** 22 | * 一条导出链路 23 | * 24 | * @author xiangfeng.xzc 25 | * @date 2018/11/14 26 | */ 27 | public interface ExportChain { 28 | Exporter exporter(); 29 | 30 | /** 31 | * @param t 32 | */ 33 | void accept(T t); 34 | } 35 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/filter/AbstractFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.filter; 18 | 19 | /** 20 | * @author xiangfeng.xzc 21 | * @date 2018/11/16 22 | */ 23 | public abstract class AbstractFilter implements Filter { 24 | private final String name; 25 | 26 | public AbstractFilter() { 27 | this.name = getClass().getSimpleName(); 28 | } 29 | 30 | public AbstractFilter(String name) { 31 | this.name = name; 32 | } 33 | 34 | @Override 35 | public String name() { 36 | return name; 37 | } 38 | 39 | protected static FilterResult fail(String msg) { 40 | return new FilterResult(msg); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/filter/FilterManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.filter; 18 | 19 | import java.util.Map; 20 | import java.util.function.Predicate; 21 | 22 | /** 23 | * filterManager 其实也是一个filter, 复合了多个filter, 但目前不让它实现filter接口. 24 | * 25 | * @author xiangfeng.xzc 26 | * @date 2018/11/22 27 | */ 28 | public interface FilterManager { 29 | Filter.FilterResult SUCCESS = Filter.SUCCESS; 30 | 31 | Filter.FilterResult test(T t, Map filterContext); 32 | 33 | default Predicate asPredicate(Map filterContext) { 34 | return t -> test(t, filterContext) == SUCCESS; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/filter/PreFilterManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.filter; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * TODO 如果前置过滤器和后置计算过滤器没太大区别的话就做成一个类吧 TODO 集成 动态 能力 23 | * 24 | * @author xiangfeng.xzc 25 | * @date 2018/11/22 26 | */ 27 | public class PreFilterManager extends AbstractFilterManager { 28 | 29 | public PreFilterManager(List> staticFilters) { 30 | super(staticFilters, null); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/filter/parser/FilterParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.filter.parser; 18 | 19 | import com.alipay.sofa.lookout.gateway.core.prototype.filter.Filter; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * 从配置解析出一个filter 25 | * 26 | * @author xiangfeng.xzc 27 | * @date 2018/11/29 28 | */ 29 | public interface FilterParser { 30 | /** 31 | * 因为各个filter需要的参数不一样, 因此只能用一个map来封装参数 32 | * 33 | * @param args 34 | * @return 35 | */ 36 | Filter parse(Map args); 37 | } 38 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/importer/Importer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.importer; 18 | 19 | import com.alipay.sofa.lookout.gateway.core.prototype.lifecycle.LifeCycle; 20 | 21 | import java.util.function.Consumer; 22 | 23 | /** 24 | * @author: kevin.luy@antfin.com 25 | * @author xiangfeng.xzc 26 | * @date 2018/11/13 27 | */ 28 | public interface Importer extends LifeCycle { 29 | /** 30 | * 返回该importer的名字, 做统计用 31 | * @return 32 | */ 33 | String name(); 34 | 35 | /** 36 | * 添加一个消费者监听该importer 37 | * 38 | * @param consumer 39 | */ 40 | void addConsumer(Consumer consumer); 41 | } 42 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/lifecycle/LifeCycle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.lifecycle; 18 | 19 | /** 20 | * 生命周期接口, TODO 还没有很好的利用上!? 21 | * 22 | * @author xiangfeng.xzc 23 | * @date 2018/11/13 24 | */ 25 | public interface LifeCycle { 26 | /** 27 | * 启动 28 | */ 29 | default void start() { 30 | } 31 | 32 | /** 33 | * 停止 34 | */ 35 | default void stop() { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/pipeline/NoInputProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.pipeline; 18 | 19 | /** 20 | * 没有输入的Processor 21 | * 22 | * @author xiangfeng.xzc 23 | * @date 2018/11/13 24 | */ 25 | public class NoInputProcessor extends AbstractProcessor { 26 | @Override 27 | public final void onInput(I i) { 28 | throw new UnsupportedOperationException(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/queue/DequeueThread.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.queue; 18 | 19 | /** 20 | * 只有这个线程才允许执行出队操作, 这是为了防止因为为了防止ThreadLocalBuffer导致数据丢失. 21 | * 考虑这个场景: 一个用户线程往buffer里加了1一条数据, 然后再也没加过数据, 那么这个buffer将一直存着直到线程灭亡, 然后数据就丢了. 22 | * 23 | * @author xiangfeng.xzc 24 | * @date 2018/11/23 25 | */ 26 | public class DequeueThread extends Thread { 27 | public DequeueThread(Runnable target) { 28 | super(target); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/queue/Serializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.queue; 18 | 19 | /** 20 | * 队列用的序列化器, 对象与byte[]的互转 21 | * 22 | * @author xiangfeng.xzc 23 | * @date 2018/11/29 24 | */ 25 | public interface Serializer { 26 | byte[] serialize(T t); 27 | 28 | T deserialize(byte[] bytes); 29 | } 30 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/reader/AbstractReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.reader; 18 | 19 | /** 20 | * @author xiangfeng.xzc 21 | * @date 2018/11/16 22 | */ 23 | public abstract class AbstractReader implements Reader { 24 | /** 25 | * 读一个UTF8字符串 26 | * 27 | * @param body 28 | * @return 29 | */ 30 | protected static String readUTF8(byte[] body) { 31 | return new String(body, UTF8); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/prototype/reader/Reader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.prototype.reader; 18 | 19 | import java.nio.charset.Charset; 20 | import java.nio.charset.StandardCharsets; 21 | import java.util.stream.Stream; 22 | 23 | /** 24 | * @author: kevin.luy@antfin.com 25 | * @author xiangfeng.xzc 26 | * @date 2018/11/15 27 | */ 28 | public interface Reader { 29 | Charset UTF8 = StandardCharsets.UTF_8; 30 | 31 | Stream read(I i); 32 | } 33 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/queue/Writable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.queue; 18 | 19 | import java.nio.ByteBuffer; 20 | 21 | /** 22 | * 23 | * @author zhangzhuo 24 | * @version $Id: Writable.java, v 0.1 2018年10月23日 下午2:43 zhangzhuo Exp $ 25 | */ 26 | public interface Writable { 27 | 28 | int getLength(); 29 | 30 | void writeTo(ByteBuffer buffer); 31 | } -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/ratelimit/RateLimitService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.ratelimit; 18 | 19 | /** 20 | * 限制客户端上传的速度, 单位是 次/秒, -1表示不限制 21 | * 22 | * @author xiangfeng.xzc 23 | * @date 2018/10/23 24 | */ 25 | public interface RateLimitService { 26 | /** 27 | * key需要amount的量 28 | * 29 | * @param key 30 | * @param amount 31 | * @return 32 | */ 33 | boolean tryAcquire(String key, int amount); 34 | 35 | /** 36 | * 获得指定的key的限速值, -1表示不限制 37 | * 38 | * @param key 39 | * @return 40 | */ 41 | int getKeyLimit(String key); 42 | } 43 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/ratelimit/impl/RateLimitConfigProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.ratelimit.impl; 18 | 19 | import java.util.Map; 20 | import java.util.function.Consumer; 21 | 22 | /** 23 | * @author xiangfeng.xzc 24 | * @date 2018/12/3 25 | */ 26 | public interface RateLimitConfigProvider { 27 | /** 28 | * 获取配置, key是app, value通常是一个int(如果确定是这样的话那么就改成Integer吧!), 表示该key对应的最大QPS 29 | * @return 30 | */ 31 | Map getConfigs(); 32 | 33 | /** 34 | * 设置监听器, 会覆盖掉之前的 35 | * @param consumer 36 | */ 37 | void setListener(Consumer> consumer); 38 | } 39 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/ratelimit/impl/UnlimitedRateLimitService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.ratelimit.impl; 18 | 19 | import com.alipay.sofa.lookout.gateway.core.ratelimit.RateLimitService; 20 | 21 | /** 22 | * 空实现, 不限速 23 | * 24 | * @author xiangfeng.xzc 25 | * @date 2018/10/23 26 | */ 27 | @SuppressWarnings("unused") 28 | public class UnlimitedRateLimitService implements RateLimitService { 29 | @Override 30 | public boolean tryAcquire(String key, int amount) { 31 | return true; 32 | } 33 | 34 | @Override 35 | public int getKeyLimit(String key) { 36 | return -1; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/reader/InputMessageReaderManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.reader; 18 | 19 | import java.util.stream.Stream; 20 | 21 | /** 22 | * @author: kevin.luy@antfin.com 23 | * @create: 2019-02-01 15:34 24 | **/ 25 | public interface InputMessageReaderManager { 26 | 27 | Stream read(I input); 28 | } 29 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/scrape/JobBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.scrape; 18 | 19 | import com.alipay.sofa.lookout.gateway.core.scrape.config.ScrapeConfig; 20 | 21 | /** 22 | * @author: kevin.luy@antfin.com 23 | * @create: 2019-01-03 23:42 24 | **/ 25 | public interface JobBuilder { 26 | ScrapeJob build(ScrapeConfig config); 27 | } 28 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/scrape/JobConfigResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.scrape; 18 | 19 | import com.alipay.sofa.lookout.gateway.core.scrape.config.ScrapeConfig; 20 | 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | /** 25 | * @author: kevin.luy@antfin.com 26 | * @create: 2019-01-04 11:32 27 | **/ 28 | public interface JobConfigResolver { 29 | 30 | List resolve(String configId, long configLastModifiedTime, 31 | Map configsMap); 32 | } 33 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/token/LookoutTokenService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.token; 18 | 19 | import com.alipay.sofa.lookout.server.common.AccessToken; 20 | 21 | /** 22 | * 异步校验token合法性 23 | * 24 | * @author xiangfeng.xzc 25 | * @date 2018/10/10 26 | */ 27 | public interface LookoutTokenService { 28 | /** 29 | * 检查token合法性 30 | * 31 | * @param token 32 | * @return 33 | */ 34 | boolean checkToken(String token); 35 | 36 | /** 37 | * 从缓存里找出token信息, 如果找不到返回null即可 38 | * 39 | * @param token 40 | * @return 41 | */ 42 | AccessToken findAccessTokenInCache(String token); 43 | } 44 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/token/impl/NoopLookoutTokenService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.token.impl; 18 | 19 | import com.alipay.sofa.lookout.gateway.core.token.LookoutTokenService; 20 | import com.alipay.sofa.lookout.server.common.AccessToken; 21 | 22 | /** 23 | * @author xiangfeng.xzc 24 | * @date 2018/11/28 25 | */ 26 | public class NoopLookoutTokenService implements LookoutTokenService { 27 | @Override 28 | public boolean checkToken(String token) { 29 | return true; 30 | } 31 | 32 | @Override 33 | public AccessToken findAccessTokenInCache(String token) { 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.utils; 18 | 19 | import com.alibaba.fastjson.JSONObject; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * @author xiangfeng.xzc 25 | * @date 2018/12/25 26 | */ 27 | public final class JsonUtils { 28 | private JsonUtils() { 29 | } 30 | 31 | public static JSONObject warpAsJson(Map map) { 32 | if (map instanceof JSONObject) { 33 | return (JSONObject) map; 34 | } 35 | // 这个方法代价很小, 因为内部是直接持有map的引用的, 并没有进行深复制 36 | return new JSONObject(map); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/utils/ListUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.utils; 18 | 19 | import java.util.ArrayList; 20 | import java.util.Collections; 21 | import java.util.List; 22 | 23 | /** 24 | * @author xiangfeng.xzc 25 | * @date 2018/11/23 26 | */ 27 | public final class ListUtils { 28 | private ListUtils() { 29 | } 30 | 31 | public static List unmodifiableList(List original) { 32 | return original == null ? Collections.emptyList() : Collections.unmodifiableList(new ArrayList<>(original)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /gateway/core/src/main/java/com/alipay/sofa/lookout/gateway/core/utils/MapUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.core.utils; 18 | 19 | import java.util.Collections; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | /** 24 | * @author xiangfeng.xzc 25 | * @date 2018/11/26 26 | */ 27 | public final class MapUtils { 28 | private MapUtils() { 29 | } 30 | 31 | public static Map unmodifiableMap(Map map) { 32 | if (map == null) { 33 | return Collections.emptyMap(); 34 | } 35 | return Collections.unmodifiableMap(new HashMap<>(map)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /gateway/metrics/exporter/elasticsearch/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | com.alipay.sofa.lookout 7 | lookout-gateway-parent 8 | 1.6.1 9 | ../../../ 10 | 11 | 4.0.0 12 | metrics-exporter-es 13 | 14 | 15 | 16 | com.alipay.sofa.lookout 17 | metrics-gateway-pipeline 18 | 19 | 20 | com.alipay.sofa.lookout 21 | gateway-core 22 | 23 | 24 | org.elasticsearch.client 25 | rest 26 | 27 | 28 | org.springframework.boot 29 | spring-boot 30 | provided 31 | 32 | 33 | junit 34 | junit 35 | test 36 | 37 | 38 | -------------------------------------------------------------------------------- /gateway/metrics/exporter/elasticsearch/src/main/java/com/alipay/sofa/lookout/gateway/metrics/exporter/es/common/ESConsts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.metrics.exporter.es.common; 18 | 19 | /** 20 | * @author: kevin.luy@antfin.com 21 | * @create: 2019-05-08 11:44 22 | **/ 23 | public interface ESConsts { 24 | String DEFAULT_ES_HOST = "localhost"; 25 | String DEFAULT_ES_INDEX = "metrics"; 26 | String DEFAULT_ES_TYPE = "metrics"; 27 | } 28 | -------------------------------------------------------------------------------- /gateway/metrics/importer/metricbeat/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | com.alipay.sofa.lookout 7 | lookout-gateway-parent 8 | 1.6.1 9 | ../../../ 10 | 11 | 4.0.0 12 | metrics-importer-metricbeat 13 | 14 | 15 | 16 | com.alipay.sofa.lookout 17 | metrics-gateway-pipeline 18 | 19 | 20 | com.alipay.sofa.lookout 21 | gateway-core 22 | 23 | 24 | org.springframework 25 | spring-context 26 | provided 27 | 28 | 29 | junit 30 | junit 31 | test 32 | 33 | 34 | -------------------------------------------------------------------------------- /gateway/metrics/importer/opentsdb/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | com.alipay.sofa.lookout 7 | lookout-gateway-parent 8 | 1.6.1 9 | ../../../ 10 | 11 | 4.0.0 12 | metrics-importer-opentsdb 13 | 14 | 15 | 16 | com.alipay.sofa.lookout 17 | metrics-gateway-pipeline 18 | 19 | 20 | org.springframework 21 | spring-context 22 | provided 23 | 24 | 25 | junit 26 | junit 27 | test 28 | 29 | 30 | -------------------------------------------------------------------------------- /gateway/metrics/importer/prometheus/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | com.alipay.sofa.lookout 7 | lookout-gateway-parent 8 | 1.6.1 9 | ../../../ 10 | 11 | 4.0.0 12 | metrics-importer-prometheus 13 | 14 | 15 | 16 | com.alipay.sofa.lookout 17 | metrics-gateway-pipeline 18 | 19 | 20 | com.alipay.sofa.lookout 21 | gateway-core 22 | 23 | 24 | com.squareup.okhttp3 25 | okhttp 26 | 27 | 28 | org.springframework 29 | spring-context 30 | provided 31 | 32 | 33 | junit 34 | junit 35 | test 36 | 37 | 38 | -------------------------------------------------------------------------------- /gateway/metrics/importer/prometheus/src/test/resources/static_targets_config.yml: -------------------------------------------------------------------------------- 1 | metric_scrape_configs: 2 | - job_name: prometheus 3 | metrics_path: /metrics 4 | scheme: http 5 | scrape_interval: 5s 6 | params: 7 | 'match[]': 8 | - '{job="prometheus"}' 9 | - '{__name__=~"job:.*"}' 10 | static_configs: 11 | - targets: ['localhost:1234'] 12 | labels: 13 | group: 'canary' 14 | 15 | - job_name: 'federate' 16 | scrape_interval: 15s 17 | metrics_path: '/federate' 18 | params: 19 | 'match[]': 20 | - '{job="prometheus"}' 21 | - '{__name__=~"job:.*"}' 22 | static_configs: 23 | - targets: 24 | - 'confkeepermain-d6719.alipay.net:9090' -------------------------------------------------------------------------------- /gateway/metrics/importer/standard/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | com.alipay.sofa.lookout 7 | lookout-gateway-parent 8 | 1.6.1 9 | ../../../ 10 | 11 | 4.0.0 12 | metrics-importer-standard 13 | 14 | 15 | 16 | com.alipay.sofa.lookout 17 | metrics-gateway-pipeline 18 | 19 | 20 | org.xerial.snappy 21 | snappy-java 22 | 23 | 24 | org.springframework 25 | spring-context 26 | provided 27 | 28 | 29 | -------------------------------------------------------------------------------- /gateway/metrics/pipeline/src/main/java/com/alipay/sofa/lookout/gateway/metrics/pipeline/exporter/DynamicExportChainProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.metrics.pipeline.exporter; 18 | 19 | import com.alipay.sofa.lookout.gateway.core.prototype.exporter.chain.ExportChain; 20 | import com.alipay.sofa.lookout.gateway.metrics.pipeline.model.Metric; 21 | 22 | import java.util.List; 23 | import java.util.function.Supplier; 24 | 25 | /** 26 | * TODO 本意是封装提供动态 ExportChain 的逻辑 27 | * 28 | * @author xiangfeng.xzc 29 | * @date 2018/11/28 30 | */ 31 | public interface DynamicExportChainProvider extends Supplier>> { 32 | } 33 | -------------------------------------------------------------------------------- /gateway/metrics/pipeline/src/main/java/com/alipay/sofa/lookout/gateway/metrics/pipeline/exporter/ExportChainFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.metrics.pipeline.exporter; 18 | 19 | /** 20 | * @author xiangfeng.xzc 21 | * @date 2018/11/28 22 | */ 23 | public interface ExportChainFactory { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /gateway/metrics/pipeline/src/main/java/com/alipay/sofa/lookout/gateway/metrics/pipeline/model/SourceType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.metrics.pipeline.model; 18 | 19 | /** 20 | * @author xiangfeng.xzc 21 | * @date 2018/11/13 22 | */ 23 | public enum SourceType { 24 | STANDARD, PROMETHEUS, OPENTSDB, METRICBEAT 25 | } 26 | -------------------------------------------------------------------------------- /gateway/metrics/pipeline/src/main/java/com/alipay/sofa/lookout/gateway/metrics/pipeline/reader/ReaderManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.gateway.metrics.pipeline.reader; 18 | 19 | import com.alipay.sofa.lookout.gateway.metrics.pipeline.model.Metric; 20 | import com.alipay.sofa.lookout.gateway.metrics.pipeline.model.RawMetric; 21 | 22 | import java.util.stream.Stream; 23 | 24 | /** 25 | * 可以做成泛型 提到prototype里 26 | * @author: kevin.luy@antfin.com 27 | * @author xiangfeng.xzc 28 | * @date 2018/11/15 29 | */ 30 | public interface ReaderManager { 31 | Stream read(RawMetric rm); 32 | } 33 | -------------------------------------------------------------------------------- /gateway/metrics/starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.alipay.sofa.lookout.gateway.metrics.starter.MetricPipelineConfiguration -------------------------------------------------------------------------------- /samples/metrics/client/lookout-client-samples-boot/README.md: -------------------------------------------------------------------------------- 1 | ## 这里演示与 SpringBoot Actuator 集成,以 lookout 作为 metrics 注册表; 2 | 3 | - 添加依赖 4 | 5 | ``` 6 | 7 | org.springframework.boot 8 | spring-boot-starter-actuator 9 | 10 | ``` 11 | 12 | - 启动后访问:http://localhost:8080/metrics 13 | 14 | ``` 15 | ... 16 | http_requests_total.instant-luyideMacBook-Pro.local: 1, 17 | ... 18 | ``` -------------------------------------------------------------------------------- /samples/metrics/client/lookout-client-samples-boot/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | management.security.enabled=false 2 | spring.application.name=lookout-client-samples-boot 3 | com.alipay.sofa.lookout.agent-host-address=127.0.0.1 4 | com.alipay.sofa.lookout.exporter-enable=true -------------------------------------------------------------------------------- /samples/metrics/client/lookout-client-samples-dropwizard-boot/README.md: -------------------------------------------------------------------------------- 1 | ## 这里演示基于 dropwizard metrics 为基础注册表与 SpringBoot Actuator 集成 2 | 3 | - 添加依赖 4 | 5 | ``` 6 | 7 | com.alipay.sofa.lookout 8 | lookout-reg-dropwizard 9 | 10 | 11 | io.dropwizard.metrics 12 | metrics-core 13 | 14 | ``` 15 | 16 | - 启动后访问:http://localhost:8080/metrics 17 | 18 | ``` 19 | ... 20 | http_requests_total.instant-luyideMacBook-Pro.local: 1, 21 | ... 22 | ``` -------------------------------------------------------------------------------- /samples/metrics/client/lookout-client-samples-dropwizard-boot/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | management.security.enabled=false 2 | spring.application.name=lookout-client-samples-boot 3 | #com.alipay.sofa.lookout.agent-host-address=localhost -------------------------------------------------------------------------------- /samples/metrics/client/lookout-client-samples-java/README.md: -------------------------------------------------------------------------------- 1 | Start it, and wait for 2 minutes at least. 2 | 3 | Wait the following logs on the console: 4 | 5 | ``` 6 | ==> [{"time":"2018-06-05T16:41:00+08:00","tags":{"app":"appName","ip":"10.15... 7 | ``` 8 | 9 | - we also add log4j2 dependency in order to print client logs in home directory. -------------------------------------------------------------------------------- /samples/metrics/client/lookout-client-samples-prometheus/README.md: -------------------------------------------------------------------------------- 1 | ## 1.加入依赖 2 | 3 | ```xml 4 | 5 | com.alipay.sofa.lookout 6 | lookout-sofa-boot-starter 7 | ${lookout.client.version} 8 | 9 | 10 | com.alipay.sofa.lookout 11 | lookout-reg-prometheus 12 | ${lookout.client.version} 13 | 14 | ``` 15 | 16 | ## 2.启动samples,后可以访问:http://localhost:9494 17 | 18 | 端口可以改变,配置项:`com.alipay.sofa.lookout.prometheus-exporter-server-port` 19 | 20 | ## 3.可以配合 prometheus 服务查看 21 | 22 | - prometheus.yml 编辑可以抓取该项目信息,假设本机IP:10.15.232.20 23 | 24 | ``` 25 | scrape_configs: 26 | - job_name: 'lookout-client' 27 | scrape_interval: 5s 28 | static_configs: 29 | - targets: ['10.15.232.20:9494'] 30 | 31 | ``` 32 | - 本地运行 prometheus docker 33 | 34 | ``` 35 | docker run -d -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml --name prom prom/prometheus:master 36 | ``` 37 | 38 | - 浏览器访问: http://localhost:9090 -------------------------------------------------------------------------------- /samples/metrics/client/lookout-client-samples-prometheus/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=lookout-client-samples-boot 2 | com.alipay.sofa.lookout.prometheus-exporter-server-port=9494 3 | logging.level.com.alipay.lookout=debug -------------------------------------------------------------------------------- /samples/metrics/client/lookout-samples-prom-push/src/main/java/com/alipay/sofa/lookout/samples/PushDemo.java: -------------------------------------------------------------------------------- 1 | package com.alipay.sofa.lookout.samples; 2 | 3 | import io.prometheus.client.CollectorRegistry; 4 | import io.prometheus.client.Counter; 5 | import io.prometheus.client.exporter.PushGateway; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | /** 13 | * @author: kevin.luy@antfin.com 14 | * @create: 2019-05-30 17:54 15 | **/ 16 | @SpringBootApplication 17 | public class PushDemo { 18 | public static void main(String[] args) throws Exception { 19 | SpringApplication.run(PushDemo.class, args); 20 | executeBatchJob(); 21 | } 22 | 23 | static void executeBatchJob() throws Exception { 24 | CollectorRegistry registry = CollectorRegistry.defaultRegistry; 25 | Counter requests = Counter.build() 26 | .name("my_library_requests_total").help("Total requests.") 27 | .labelNames("method").register(); 28 | requests.labels("get").inc(); 29 | 30 | 31 | PushGateway pushgateway = new PushGateway("127.0.0.1:7200/prom"); 32 | // pushgateway.setConnectionFactory(new BasicAuthHttpConnectionFactory("my_user", "my_password")); 33 | Map groupingkeys = new HashMap<>(); 34 | groupingkeys.put("app", "xx"); 35 | pushgateway.pushAdd(registry, "my_batch_job", groupingkeys); 36 | // pushgateway.pushAdd(registry, "my_batch_job"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /server/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | +----------------------------+ 3 | | | 4 | | metircs-server-interfaces | 5 | | | 6 | +----------------------------+ 7 | 8 | +----------------------------+ 9 | | | 10 | | metrics-server-promql | 11 | | | 12 | +----------------------------+ 13 | 14 | +----------------------------+ 15 | | | 16 | | metrics-storage-ext-* | 17 | | | 18 | +----------------------------+ 19 | 20 | ``` -------------------------------------------------------------------------------- /server/common/src/main/java/com/alipay/sofa/lookout/server/common/es/operation/ESDataType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.common.es.operation; 18 | 19 | /** 20 | * @author: kevin.luy@antfin.com 21 | * @create: 2019-05-13 14:53 22 | **/ 23 | public enum ESDataType { 24 | METRIC 25 | } 26 | -------------------------------------------------------------------------------- /server/metrics/interfaces/src/main/java/com/alipay/sofa/lookout/server/interfaces/model/ScalarResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.interfaces.model; 18 | 19 | import com.alipay.sofa.lookout.server.interfaces.common.TimestampUtil; 20 | import com.alipay.sofa.lookout.server.prom.ql.value.Scalar; 21 | 22 | /** 23 | * @author: kevin.luy@antfin.com 24 | * @create: 2019-06-05 14:17 25 | **/ 26 | public class ScalarResult { 27 | 28 | public static Object[] from(Scalar scalar) { 29 | Object[] value = new Object[2]; 30 | value[0] = TimestampUtil.mills2sec(scalar.getT()); 31 | value[1] = String.valueOf(scalar.getV()); 32 | return value; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/common/QueryConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.common; 18 | 19 | /** 20 | * @author: kevin.luy@antfin.com 21 | * @create: 2019-04-28 22:39 22 | **/ 23 | public interface QueryConstants { 24 | 25 | long MAX_DATA_POINTS = 100000L; 26 | long MAX_LABEL_SIZE = 10000L; 27 | 28 | String EXPRESSION_CONTEXT = "expr_ctxt"; 29 | } 30 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/exception/TooManyPointsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.exception; 18 | 19 | /** 20 | * Created by kevin.luy@alipay.com on 2018/4/21. 21 | */ 22 | public class TooManyPointsException extends RuntimeException { 23 | private long limitSize = 100000; 24 | 25 | /** 26 | * @param size the size of data points 27 | */ 28 | public TooManyPointsException(long size) { 29 | super(); 30 | this.limitSize = size; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/Card.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | /** 20 | * Cardinality. 表示实体之前的数值关系(1对1,多对1....) 21 | * Created by kevin.luy@alipay.com on 2018/2/10. 22 | */ 23 | public enum Card { 24 | CardOneToOne, CardManyToOne, CardOneToMany, CardManyToMany 25 | } 26 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/Expr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | import com.alipay.sofa.lookout.server.prom.ql.value.ValueType; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2018/2/7. 23 | */ 24 | public interface Expr extends Node { 25 | /** 26 | * 27 | * @return ValueType 28 | */ 29 | ValueType type(); 30 | 31 | void expr(); 32 | } 33 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/Expressions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * Created by kevin.luy@alipay.com on 2018/2/11. 24 | */ 25 | public class Expressions implements Node { 26 | List expressions = new ArrayList<>(); 27 | 28 | public List getExpressions() { 29 | return expressions; 30 | } 31 | 32 | public void add(Expr expr) { 33 | expressions.add(expr); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/Node.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | /** 20 | * Created by kevin.luy@alipay.com on 2018/2/10. 21 | */ 22 | public interface Node { 23 | } 24 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/NodeInspector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | /** 20 | * NodeInspector is a node visitor. You can customize your inspection logic. 21 | * 22 | * @author: kevin.luy@antfin.com 23 | * @create: 2019-04-23 21:23 24 | **/ 25 | public interface NodeInspector extends Visitor { 26 | 27 | @Override 28 | default Visitor visit(Node node) { 29 | if (inspect(node)) { 30 | return this; 31 | } 32 | return null; 33 | } 34 | 35 | /** 36 | * how to inspect a node. 37 | * 38 | * @param node 39 | * @return 40 | */ 41 | boolean inspect(Node node); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/ParenExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | import com.alipay.sofa.lookout.server.prom.ql.value.ValueType; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2018/2/10. 23 | */ 24 | public class ParenExpr implements Expr { 25 | Expr expr; 26 | 27 | public ParenExpr(Expr expr) { 28 | this.expr = expr; 29 | } 30 | 31 | public Expr getExpr() { 32 | return expr; 33 | } 34 | 35 | @Override 36 | public ValueType type() { 37 | return expr.type(); 38 | } 39 | 40 | @Override 41 | public void expr() { 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/RecordStmt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | import com.alipay.sofa.lookout.server.prom.labels.Labels; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2018/2/10. 23 | */ 24 | public class RecordStmt implements Statement { 25 | String name; 26 | Expr expr; 27 | Labels labels; 28 | 29 | public RecordStmt(String name, Expr expr, Labels labels) { 30 | this.name = name; 31 | this.expr = expr; 32 | this.labels = labels; 33 | } 34 | 35 | @Override 36 | public void stmt() { 37 | } 38 | 39 | public Expr getExpr() { 40 | return expr; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/Statement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | /** 20 | * Created by kevin.luy@alipay.com on 2018/2/7. 21 | */ 22 | public interface Statement extends Node { 23 | void stmt(); 24 | } 25 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/Statements.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * Created by kevin.luy@alipay.com on 2018/2/11. 24 | */ 25 | public class Statements implements Node { 26 | 27 | List stmts = new ArrayList<>(); 28 | 29 | public List getStmts() { 30 | return stmts; 31 | } 32 | 33 | public void add(Statement stmt) { 34 | stmts.add(stmt); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/StringLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | import com.alipay.sofa.lookout.server.prom.ql.value.ValueType; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2018/2/10. 23 | */ 24 | public class StringLiteral implements Expr { 25 | 26 | String val; 27 | 28 | public StringLiteral(String val) { 29 | this.val = val; 30 | } 31 | 32 | public String getVal() { 33 | return val; 34 | } 35 | 36 | @Override 37 | public ValueType type() { 38 | return ValueType.string; 39 | } 40 | 41 | @Override 42 | public void expr() { 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/ast/Visitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.ast; 18 | 19 | /** 20 | * Visitor allows visiting a Node and its child nodes. 21 | *

22 | * Created by kevin.luy@alipay.com on 2018/2/10. 23 | */ 24 | interface Visitor { 25 | /** 26 | * The Visit method is invoked for each node encountered by Walk. 27 | * 28 | * @param node 29 | * @return 30 | */ 31 | Visitor visit(Node node); 32 | } 33 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/engine/MetricSignCalculator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.engine; 18 | 19 | import com.alipay.sofa.lookout.server.prom.labels.Labels; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2018/2/16. 23 | */ 24 | @FunctionalInterface 25 | public interface MetricSignCalculator { 26 | 27 | long invoke(Labels labels); 28 | } 29 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/func/AggrFn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.func; 18 | 19 | import com.alipay.sofa.lookout.server.prom.ql.value.Series; 20 | 21 | import java.util.Set; 22 | 23 | /** 24 | * Created by kevin.luy@alipay.com on 2018/2/23. 25 | */ 26 | @FunctionalInterface 27 | public interface AggrFn { 28 | 29 | double invoke(Set points); 30 | } 31 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/func/FuncCallFn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.func; 18 | 19 | import com.alipay.sofa.lookout.server.prom.ql.ast.Expressions; 20 | import com.alipay.sofa.lookout.server.prom.ql.engine.Evaluator; 21 | import com.alipay.sofa.lookout.server.prom.ql.value.Value; 22 | 23 | /** 24 | * Created by kevin.luy@alipay.com on 2018/2/12. 25 | */ 26 | @FunctionalInterface 27 | public interface FuncCallFn { 28 | 29 | Value invoke(Evaluator ev, Expressions args); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/lex/StateFn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.lex; 18 | 19 | /** 20 | * Created by kevin.luy@alipay.com on 2018/2/7. 21 | */ 22 | @FunctionalInterface 23 | public interface StateFn { 24 | StateFn invoke(Lexer lexer); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/parse/SequenceValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.parse; 18 | 19 | /** 20 | * Created by kevin.luy@alipay.com on 2018/2/10. 21 | */ 22 | public class SequenceValue { 23 | float value; 24 | boolean omitted; 25 | 26 | @Override 27 | public String toString() { 28 | if (omitted) { 29 | return "_"; 30 | } 31 | return String.format("%s", value); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/value/Value.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.value; 18 | 19 | /** 20 | * Created by kevin.luy@alipay.com on 2018/2/7. 21 | */ 22 | public interface Value { 23 | ValueType type(); 24 | } 25 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/ql/value/ValueType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.value; 18 | 19 | /** 20 | * Created by kevin.luy@alipay.com on 2018/2/10. 21 | */ 22 | public enum ValueType { 23 | none, vector, scalar, matrix, string; 24 | } 25 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/storage/Storage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.storage; 18 | 19 | import com.alipay.sofa.lookout.server.prom.storage.query.Querier; 20 | 21 | /** 22 | * store time serial data. 23 | * 24 | * @author: kevin.luy@antfin.com 25 | * @create: 2019-04-28 12:20 26 | **/ 27 | public interface Storage { 28 | 29 | Querier querier(); 30 | 31 | /** 32 | * whether this storage service supports an aggregate query. 33 | * 34 | * @return 35 | */ 36 | boolean isAggregatable(String aggregator); 37 | 38 | boolean isHealthy(); 39 | 40 | void start(); 41 | 42 | long startTime(); 43 | 44 | void close(); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/storage/query/AggregateStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.storage.query; 18 | 19 | import com.alipay.sofa.lookout.server.prom.ql.lex.ItemType; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author: kevin.luy@antfin.com 25 | * @create: 2019-04-28 22:14 26 | **/ 27 | public interface AggregateStatement extends QueryStatement { 28 | 29 | ItemType aggregator(); 30 | 31 | List groups(); 32 | 33 | AggregateStatement setGroups(List groups); 34 | 35 | AggregateStatement setAggregator(ItemType aggregator); 36 | } 37 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/storage/query/MetadataStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.storage.query; 18 | 19 | /** 20 | * @author: kevin.luy@antfin.com 21 | * @create: 2019-04-28 22:31 22 | **/ 23 | public interface MetadataStatement { 24 | 25 | String getQueryContent(); 26 | 27 | MetadataStatement setQueryContent(String queryContent); 28 | 29 | long getSize(); 30 | 31 | MetadataStatement setSize(long size); 32 | 33 | T executeQuery(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/storage/query/Querier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.storage.query; 18 | 19 | import com.alipay.sofa.lookout.server.prom.ql.lex.ItemType; 20 | 21 | /** 22 | * @author: kevin.luy@antfin.com 23 | * @create: 2019-04-29 14:47 24 | **/ 25 | public interface Querier { 26 | 27 | QueryStatement createQueryStmt(); 28 | 29 | AggregateStatement createAggregateStmt(); 30 | 31 | MetadataStatement createLabelNamesStmt(); 32 | 33 | LabelValuesStatement createLabelValuesStmt(); 34 | 35 | boolean supportAggregator(ItemType aggregationType); 36 | } 37 | -------------------------------------------------------------------------------- /server/metrics/promql/src/main/java/com/alipay/sofa/lookout/server/prom/util/NoopUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.util; 18 | 19 | /** 20 | * @author xiangfeng.xzc 21 | * @date 2018/10/17 22 | */ 23 | public final class NoopUtils { 24 | private NoopUtils() { 25 | } 26 | 27 | public static void noop() { 28 | boolean x = false; 29 | while (x) { 30 | break; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/metrics/promql/src/test/java/com/alipay/sofa/lookout/server/prom/labels/LabelTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.labels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | /** 23 | * @author: kevin.luy@antfin.com 24 | * @create: 2019-04-23 11:22 25 | **/ 26 | public class LabelTest { 27 | 28 | @Test 29 | public void testLableEquals() { 30 | Label l1 = new Label("k1", "v1"); 31 | Label l2 = new Label("k1", "v1"); 32 | Assert.assertTrue(l1.equals(l2)); 33 | l2.setValue(null); 34 | Assert.assertFalse(l1.equals(l2)); 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /server/metrics/promql/src/test/java/com/alipay/sofa/lookout/server/prom/labels/MatcherTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.labels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | /** 23 | * @author: kevin.luy@antfin.com 24 | * @create: 2019-04-23 12:13 25 | **/ 26 | public class MatcherTest { 27 | 28 | @Test 29 | public void testEqualMatches() { 30 | Matcher matcher = new Matcher(MatchType.MatchEqual, "k1", "v1"); 31 | Assert.assertTrue(matcher.matches("v1")); 32 | Assert.assertFalse(matcher.matches("v2")); 33 | 34 | } 35 | 36 | //TODO add other mathtype testcase 37 | } 38 | -------------------------------------------------------------------------------- /server/metrics/promql/src/test/java/com/alipay/sofa/lookout/server/prom/ql/value/SeriesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.prom.ql.value; 18 | 19 | /** 20 | * @author: kevin.luy@antfin.com 21 | * @create: 2019-04-25 19:29 22 | **/ 23 | public class SeriesTest { 24 | //TODO test seek one and seekset; 25 | } 26 | -------------------------------------------------------------------------------- /server/metrics/promql/src/test/resources/testdata/avg_over_time.test: -------------------------------------------------------------------------------- 1 | 2019-05-27T16:38:00+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 2 | 2019-05-27T16:39:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 3 | 2019-05-27T16:40:00+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 4 | 2019-05-27T16:40:30+08:00,8,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 5 | 2019-05-27T16:41:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 6 | -------------------------------------------------------------------------------- /server/metrics/promql/src/test/resources/testdata/max_over_time.test: -------------------------------------------------------------------------------- 1 | 2019-05-27T16:38:00+08:00,27,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 2 | 2019-05-27T16:39:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 3 | 2019-05-27T16:40:00+08:00,18,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 4 | 2019-05-27T16:40:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 5 | 2019-05-27T16:41:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 6 | -------------------------------------------------------------------------------- /server/metrics/promql/src/test/resources/testdata/min_over_time.test: -------------------------------------------------------------------------------- 1 | 2019-05-27T16:38:00+08:00,0,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 2 | 2019-05-27T16:39:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 3 | 2019-05-27T16:40:00+08:00,1,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 4 | 2019-05-27T16:40:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 5 | 2019-05-27T16:41:30+08:00,2,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 6 | -------------------------------------------------------------------------------- /server/metrics/promql/src/test/resources/testdata/range_query.test: -------------------------------------------------------------------------------- 1 | 2019-05-27T16:37:30+08:00,7,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 2 | 2019-05-27T16:38:00+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 3 | 2019-05-27T16:39:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 4 | 2019-05-27T16:40:00+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 5 | 2019-05-27T16:40:30+08:00,8,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 6 | 2019-05-27T16:41:00+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 7 | -------------------------------------------------------------------------------- /server/metrics/promql/src/test/resources/testdata/sum_over_time.test: -------------------------------------------------------------------------------- 1 | 2019-05-27T16:38:00+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 2 | 2019-05-27T16:39:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 3 | 2019-05-27T16:40:00+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 4 | 2019-05-27T16:40:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 5 | 2019-05-27T16:41:30+08:00,9,app=gateway,host=local,ip=127.0.0.1,__name__=test_metric 6 | -------------------------------------------------------------------------------- /server/metrics/starter/src/main/java/com/alipay/sofa/lookout/server/starter/ServerProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.lookout.server.starter; 18 | 19 | import org.springframework.boot.context.properties.ConfigurationProperties; 20 | 21 | /** 22 | * Created by kevin.luy@alipay.com on 2018/3/23. 23 | */ 24 | @ConfigurationProperties(prefix = "metrics.server") 25 | public class ServerProperties { 26 | private String storage; 27 | 28 | public String getStorage() { 29 | return storage; 30 | } 31 | 32 | public void setStorage(String storage) { 33 | this.storage = storage; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /server/metrics/starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | # Auto Configure 2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 3 | com.alipay.sofa.lookout.server.starter.ServerAutoConfiguration -------------------------------------------------------------------------------- /server/metrics/starter/src/test/resources/config/application.properties: -------------------------------------------------------------------------------- 1 | ## spring data jest 2 | spring.data.jest.uri=http://lookout:dkZpMNJF@search.alipay.com:9999 3 | 4 | lookout.server.storage=es 5 | es.metrics.index=metrics 6 | 7 | ## not required 8 | scheduler.enable=false 9 | 10 | -------------------------------------------------------------------------------- /server/metrics/storage-ext-es/es-config/mappings: -------------------------------------------------------------------------------- 1 | curl http://localhost:9200/_cat/aliases 2 | curl http://localhost:9200/_cat/indices 3 | 4 | 5 | 6 | - index: metrics 7 | - mapping: 8 | 9 | curl -XPUT -H 'Content-Type:application/json' http://localhost:9200/active-metrics/metrics/_mapping -d ' 10 | { 11 | "properties": { 12 | "id": { 13 | "type": "keyword" 14 | }, 15 | "tags": { 16 | "type": "keyword" 17 | }, 18 | "time": { 19 | "type": "date" 20 | }, 21 | "value": { 22 | "type": "float" 23 | } 24 | } 25 | }' 26 | 27 | 28 | 29 | - create index alias 30 | 31 | ``` 32 | curl -XPUT -H 'Content-Type:application/json' http://localhost:9200/_template/active-metrics -d ' 33 | { 34 | "template": "metrics-*", 35 | "settings": { 36 | "number_of_shards": 5, 37 | "number_of_replicas": 1, 38 | "routing.allocation.include.box_type": "hot", 39 | "routing.allocation.total_shards_per_node": 8 40 | }, 41 | "aliases": { 42 | "active-metrics": {}, 43 | "search-metrics": {} 44 | } 45 | }' 46 | ``` 47 | 48 | curl -XPUT -H 'Content-Type:application/json' http://localhost:9200/%3Cmetrics-%7Bnow%2Fd%7D-1%3E 49 | 50 | - trigger indices rollover [自带] 51 | 52 | ``` 53 | POST active-metrics/_rollover -d '{"conditions": {"max_age": "1d","max_docs": 1000000000}}' 54 | ``` 55 | 56 | - delete old indices [自带] 57 | 58 | 59 | -------------------------------------------------------------------------------- /server/metrics/web-ui/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.alipay.sofa.lookout 8 | lookout-server-parent 9 | 1.6.1 10 | ../../pom.xml 11 | 12 | 13 | metrics-web-ui 14 | metrics-webUI 15 | jar 16 | 17 | -------------------------------------------------------------------------------- /server/metrics/web-ui/src/main/resources/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Lookout Console 8 | 9 | 10 |

11 | 12 | 13 | -------------------------------------------------------------------------------- /server/server-test/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | com.alipay.sofa.lookout 7 | lookout-server-parent 8 | 1.6.1 9 | ../pom.xml 10 | 11 | 4.0.0 12 | 13 | server-test 14 | 15 | 16 | --------------------------------------------------------------------------------