├── .gitignore ├── chart ├── templates │ ├── NOTES.txt │ ├── _helpers.tpl │ ├── greeting-service.yaml │ └── greeting-deployment.yaml ├── Chart.yaml ├── values.yaml └── .helmignore ├── app ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── org │ │ └── aws │ │ └── samples │ │ └── greeting │ │ ├── Application.java │ │ └── GreetingController.java └── pom.xml ├── k8s.yaml ├── readme.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | 3 | -------------------------------------------------------------------------------- /chart/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | Get the application URL by running: 2 | $ kubectl get svc/{{ .Release.Name }}-webapp -o wide 3 | -------------------------------------------------------------------------------- /chart/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "1.0" 3 | description: | 4 | A Helm chart for a trivial web application 5 | name: app 6 | version: 0.1.0 7 | -------------------------------------------------------------------------------- /chart/values.yaml: -------------------------------------------------------------------------------- 1 | greeting: 2 | image: arungupta/greeting 3 | replicaCount: 1 4 | 5 | image: 6 | tag: prom 7 | pullPolicy: Always 8 | 9 | service: 10 | type: LoadBalancer 11 | externalPort: 80 12 | internalPort: 8080 13 | -------------------------------------------------------------------------------- /app/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #Metrics related configurations 2 | management.endpoint.metrics.enabled=true 3 | management.endpoints.web.exposure.include=* 4 | management.endpoint.prometheus.enabled=true 5 | management.metrics.export.prometheus.enabled=true -------------------------------------------------------------------------------- /chart/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{- define "labels" }} 2 | labels: 3 | generator: helm 4 | date: {{ now | htmlDate }} 5 | release: {{ .Release.Name }} 6 | revision: {{ .Release.Revision | quote }} 7 | chart: {{ .Chart.Name }} 8 | version: {{ .Chart.Version }} 9 | {{- end }} 10 | -------------------------------------------------------------------------------- /app/src/main/java/org/aws/samples/greeting/Application.java: -------------------------------------------------------------------------------- 1 | package org.aws.samples.greeting; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } -------------------------------------------------------------------------------- /chart/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | -------------------------------------------------------------------------------- /chart/templates/greeting-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ .Release.Name }}-greeting 5 | labels: 6 | name: {{ .Release.Name }}-greeting 7 | {{- template "labels" . }} 8 | spec: 9 | selector: 10 | app: {{ .Release.Name }}-greeting 11 | ports: 12 | - name: http 13 | protocol: TCP 14 | port: {{ .Values.service.externalPort }} 15 | targetPort: {{ .Values.service.internalPort }} 16 | type: LoadBalancer -------------------------------------------------------------------------------- /chart/templates/greeting-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: {{ .Release.Name }}-greeting 5 | labels: 6 | name: {{ .Release.Name }}-greeting 7 | {{- template "labels" . }} 8 | spec: 9 | replicas: {{ .Values.replicaCount }} 10 | template: 11 | metadata: 12 | labels: 13 | app: {{ .Release.Name }}-greeting 14 | spec: 15 | containers: 16 | - name: greeting 17 | image: {{ .Values.greeting.image }}:{{ .Values.image.tag }} 18 | imagePullPolicy: {{ .Values.image.pullPolicy }} 19 | ports: 20 | - containerPort: {{ .Values.service.internalPort }} 21 | name: "http" 22 | -------------------------------------------------------------------------------- /k8s.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: greeting 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | app: greeting 10 | template: 11 | metadata: 12 | labels: 13 | app: greeting 14 | spec: 15 | containers: 16 | - name: greeting 17 | image: arungupta/greeting:prom 18 | imagePullPolicy: IfNotPresent 19 | ports: 20 | - containerPort: 8080 21 | name: "http" 22 | --- 23 | apiVersion: v1 24 | kind: Service 25 | metadata: 26 | name: greeting 27 | spec: 28 | selector: 29 | app: greeting 30 | ports: 31 | - name: http 32 | protocol: TCP 33 | port: 80 34 | targetPort: 8080 35 | type: LoadBalancer 36 | -------------------------------------------------------------------------------- /app/src/main/java/org/aws/samples/greeting/GreetingController.java: -------------------------------------------------------------------------------- 1 | package org.aws.samples.greeting; 2 | 3 | import org.springframework.web.bind.annotation.RestController; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import io.prometheus.client.Counter; 6 | import io.prometheus.client.Histogram; 7 | 8 | /** 9 | * @author Arun Gupta 10 | */ 11 | @RestController 12 | public class GreetingController { 13 | 14 | // request counter metric 15 | static final Counter REQUESTS = Counter.build() 16 | .name("requests_total").help("Total number of requests.").register(); 17 | // histogram metric 18 | static final Histogram REQUESTS_LATENCY = Histogram.build() 19 | .name("requests_latency_seconds").help("Request latency in seconds.").register(); 20 | 21 | @RequestMapping("/hello") 22 | public String sayHello() { 23 | REQUESTS.inc(); 24 | Histogram.Timer requestTimer = REQUESTS_LATENCY.startTimer(); 25 | try { 26 | return "Hello World"; 27 | } finally { 28 | requestTimer.observeDuration(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.aws.samples.greeting 5 | app 6 | 1.0-SNAPSHOT 7 | jar 8 | 9 | 10 | org.springframework.boot 11 | spring-boot-starter-parent 12 | 2.1.6.RELEASE 13 | 14 | 15 | 16 | UTF-8 17 | 1.8 18 | 1.8 19 | arungupta 20 | prom 21 | registry.hub.docker.com 22 | ${docker.repo}/${project.build.finalName}:${docker.tag} 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-actuator 33 | 34 | 35 | io.micrometer 36 | micrometer-registry-prometheus 37 | 38 | 39 | io.prometheus 40 | simpleclient_spring_boot 41 | 0.6.0 42 | 43 | 44 | 45 | 46 | greeting 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-maven-plugin 51 | 52 | 53 | 54 | 55 | 56 | 57 | jib 58 | 59 | 60 | 61 | com.google.cloud.tools 62 | jib-maven-plugin 63 | 1.3.0 64 | 65 | 66 | ${docker.name} 67 | 68 | 69 | 70 | 71 | package 72 | 73 | build 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Spring Boot Application with Prometheus-style Metrics in Kubernetes 2 | 3 | This repo contains a simple Spring Boot application that publishes Proemtheus-style metrics in Kubernetes 4 | 5 | ## Java Application 6 | 7 | - Run application: 8 | 9 | ``` 10 | mvn -f app/pom.xml spring-boot:run 11 | ``` 12 | 13 | - Access the application: 14 | 15 | curl http://localhost:8080/hello 16 | 17 | - Access [metrics endpoint](http://localhost:8080/actuator/prometheus) 18 | 19 | ## Deploy to Kubernetes 20 | 21 | - Build and push Docker image: 22 | 23 | ``` 24 | mvn -f app/pom.xml package -Pjib 25 | ``` 26 | 27 | Optionally, build to Docker daemon: 28 | 29 | ``` 30 | mvn -f app/pom.xml jib:dockerBuild -Pjib 31 | ``` 32 | 33 | Alternatively, build using `Dockerfile`: 34 | 35 | ``` 36 | docker image build -t arungupta/greeting:prom . 37 | docker image push arungupta/greeting:prom 38 | ``` 39 | 40 | - Deploy to k8s: 41 | 42 | ``` 43 | helm install --name myapp chart 44 | ``` 45 | 46 | - Access the application: 47 | 48 | ``` 49 | ENDPOINT=$(kubectl get svc/myapp-greeting \ 50 | -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') 51 | curl http://$ENDPOINT/hello 52 | ``` 53 | 54 | - Access prometheus metrics at: 55 | 56 | ``` 57 | curl http://$ENDPOINT/actuator/prometheus 58 | # HELP jvm_threads_daemon_threads The current number of live daemon threads 59 | # TYPE jvm_threads_daemon_threads gauge 60 | jvm_threads_daemon_threads 16.0 61 | # HELP http_server_requests_seconds 62 | # TYPE http_server_requests_seconds summary 63 | http_server_requests_seconds_count{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/hello",} 2.0 64 | http_server_requests_seconds_sum{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/hello",} 0.040638166 65 | http_server_requests_seconds_count{exception="None",method="GET",outcome="CLIENT_ERROR",status="404",uri="/**",} 2.0 66 | http_server_requests_seconds_sum{exception="None",method="GET",outcome="CLIENT_ERROR",status="404",uri="/**",} 0.01150999 67 | # HELP http_server_requests_seconds_max 68 | # TYPE http_server_requests_seconds_max gauge 69 | http_server_requests_seconds_max{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/hello",} 0.003151873 70 | http_server_requests_seconds_max{exception="None",method="GET",outcome="CLIENT_ERROR",status="404",uri="/**",} 0.006369922 71 | # HELP tomcat_global_received_bytes_total 72 | # TYPE tomcat_global_received_bytes_total counter 73 | tomcat_global_received_bytes_total{name="http-nio-8080",} 0.0 74 | # HELP jvm_threads_live_threads The current number of live threads including both daemon and non-daemon threads 75 | # TYPE jvm_threads_live_threads gauge 76 | jvm_threads_live_threads 20.0 77 | # HELP tomcat_sessions_alive_max_seconds 78 | # TYPE tomcat_sessions_alive_max_seconds gauge 79 | tomcat_sessions_alive_max_seconds 0.0 80 | # HELP jvm_gc_memory_promoted_bytes_total Count of positive increases in the size of the old generation memory pool before GC to after GC 81 | # TYPE jvm_gc_memory_promoted_bytes_total counter 82 | jvm_gc_memory_promoted_bytes_total 1.2372152E7 83 | # HELP tomcat_global_request_max_seconds 84 | # TYPE tomcat_global_request_max_seconds gauge 85 | tomcat_global_request_max_seconds{name="http-nio-8080",} 0.065 86 | # HELP logback_events_total Number of error level events that made it to the logs 87 | # TYPE logback_events_total counter 88 | logback_events_total{level="warn",} 0.0 89 | logback_events_total{level="debug",} 0.0 90 | logback_events_total{level="error",} 0.0 91 | logback_events_total{level="trace",} 0.0 92 | logback_events_total{level="info",} 7.0 93 | # HELP tomcat_sessions_active_max_sessions 94 | # TYPE tomcat_sessions_active_max_sessions gauge 95 | tomcat_sessions_active_max_sessions 0.0 96 | # HELP process_files_max_files The maximum file descriptor count 97 | # TYPE process_files_max_files gauge 98 | process_files_max_files 65536.0 99 | # HELP jvm_memory_used_bytes The amount of used memory 100 | # TYPE jvm_memory_used_bytes gauge 101 | jvm_memory_used_bytes{area="heap",id="Tenured Gen",} 2.7163832E7 102 | jvm_memory_used_bytes{area="heap",id="Eden Space",} 6.8747016E7 103 | jvm_memory_used_bytes{area="nonheap",id="Metaspace",} 3.9226672E7 104 | jvm_memory_used_bytes{area="nonheap",id="Code Cache",} 1.072608E7 105 | jvm_memory_used_bytes{area="heap",id="Survivor Space",} 0.0 106 | jvm_memory_used_bytes{area="nonheap",id="Compressed Class Space",} 4998160.0 107 | # HELP jvm_classes_unloaded_classes_total The total number of classes unloaded since the Java virtual machine has started execution 108 | # TYPE jvm_classes_unloaded_classes_total counter 109 | jvm_classes_unloaded_classes_total 1.0 110 | # HELP process_files_open_files The open file descriptor count 111 | # TYPE process_files_open_files gauge 112 | process_files_open_files 81.0 113 | # HELP tomcat_sessions_expired_sessions_total 114 | # TYPE tomcat_sessions_expired_sessions_total counter 115 | tomcat_sessions_expired_sessions_total 0.0 116 | # HELP process_start_time_seconds Start time of the process since unix epoch. 117 | # TYPE process_start_time_seconds gauge 118 | process_start_time_seconds 1.561743338405E9 119 | # HELP jvm_buffer_memory_used_bytes An estimate of the memory that the Java virtual machine is using for this buffer pool 120 | # TYPE jvm_buffer_memory_used_bytes gauge 121 | jvm_buffer_memory_used_bytes{id="direct",} 90112.0 122 | jvm_buffer_memory_used_bytes{id="mapped",} 0.0 123 | # HELP jvm_memory_max_bytes The maximum amount of memory in bytes that can be used for memory management 124 | # TYPE jvm_memory_max_bytes gauge 125 | jvm_memory_max_bytes{area="heap",id="Tenured Gen",} 5.48339712E9 126 | jvm_memory_max_bytes{area="heap",id="Eden Space",} 2.193358848E9 127 | jvm_memory_max_bytes{area="nonheap",id="Metaspace",} -1.0 128 | jvm_memory_max_bytes{area="nonheap",id="Code Cache",} 2.5165824E8 129 | jvm_memory_max_bytes{area="heap",id="Survivor Space",} 2.74137088E8 130 | jvm_memory_max_bytes{area="nonheap",id="Compressed Class Space",} 1.073741824E9 131 | # HELP tomcat_threads_current_threads 132 | # TYPE tomcat_threads_current_threads gauge 133 | tomcat_threads_current_threads{name="http-nio-8080",} 10.0 134 | # HELP tomcat_threads_busy_threads 135 | # TYPE tomcat_threads_busy_threads gauge 136 | tomcat_threads_busy_threads{name="http-nio-8080",} 1.0 137 | # HELP jvm_gc_memory_allocated_bytes_total Incremented for an increase in the size of the young generation memory pool after one GC to before the next 138 | # TYPE jvm_gc_memory_allocated_bytes_total counter 139 | jvm_gc_memory_allocated_bytes_total 6.3571608E7 140 | # HELP jvm_classes_loaded_classes The number of classes that are currently loaded in the Java virtual machine 141 | # TYPE jvm_classes_loaded_classes gauge 142 | jvm_classes_loaded_classes 7621.0 143 | # HELP tomcat_sessions_active_current_sessions 144 | # TYPE tomcat_sessions_active_current_sessions gauge 145 | tomcat_sessions_active_current_sessions 0.0 146 | # HELP process_uptime_seconds The uptime of the Java virtual machine 147 | # TYPE process_uptime_seconds gauge 148 | process_uptime_seconds 440.611 149 | # HELP jvm_gc_live_data_size_bytes Size of old generation memory pool after a full GC 150 | # TYPE jvm_gc_live_data_size_bytes gauge 151 | jvm_gc_live_data_size_bytes 2.7163832E7 152 | # HELP process_cpu_usage The "recent cpu usage" for the Java Virtual Machine process 153 | # TYPE process_cpu_usage gauge 154 | process_cpu_usage 7.506521012208091E-6 155 | # HELP tomcat_global_error_total 156 | # TYPE tomcat_global_error_total counter 157 | tomcat_global_error_total{name="http-nio-8080",} 2.0 158 | # HELP jvm_gc_pause_seconds Time spent in GC pause 159 | # TYPE jvm_gc_pause_seconds summary 160 | jvm_gc_pause_seconds_count{action="end of major GC",cause="Metadata GC Threshold",} 1.0 161 | jvm_gc_pause_seconds_sum{action="end of major GC",cause="Metadata GC Threshold",} 0.065 162 | # HELP jvm_gc_pause_seconds_max Time spent in GC pause 163 | # TYPE jvm_gc_pause_seconds_max gauge 164 | jvm_gc_pause_seconds_max{action="end of major GC",cause="Metadata GC Threshold",} 0.0 165 | # HELP tomcat_sessions_rejected_sessions_total 166 | # TYPE tomcat_sessions_rejected_sessions_total counter 167 | tomcat_sessions_rejected_sessions_total 0.0 168 | # HELP jvm_threads_peak_threads The peak live thread count since the Java virtual machine started or peak was reset 169 | # TYPE jvm_threads_peak_threads gauge 170 | jvm_threads_peak_threads 20.0 171 | # HELP system_cpu_count The number of processors available to the Java virtual machine 172 | # TYPE system_cpu_count gauge 173 | system_cpu_count 1.0 174 | # HELP system_load_average_1m The sum of the number of runnable entities queued to available processors and the number of runnable entities running on the available processors averaged over a period of time 175 | # TYPE system_load_average_1m gauge 176 | system_load_average_1m 0.01 177 | # HELP tomcat_sessions_created_sessions_total 178 | # TYPE tomcat_sessions_created_sessions_total counter 179 | tomcat_sessions_created_sessions_total 0.0 180 | # HELP jvm_memory_committed_bytes The amount of memory in bytes that is committed for the Java virtual machine to use 181 | # TYPE jvm_memory_committed_bytes gauge 182 | jvm_memory_committed_bytes{area="heap",id="Tenured Gen",} 3.43932928E8 183 | jvm_memory_committed_bytes{area="heap",id="Eden Space",} 1.37691136E8 184 | jvm_memory_committed_bytes{area="nonheap",id="Metaspace",} 4.1680896E7 185 | jvm_memory_committed_bytes{area="nonheap",id="Code Cache",} 1.1862016E7 186 | jvm_memory_committed_bytes{area="heap",id="Survivor Space",} 1.7170432E7 187 | jvm_memory_committed_bytes{area="nonheap",id="Compressed Class Space",} 5505024.0 188 | # HELP jvm_threads_states_threads The current number of threads having NEW state 189 | # TYPE jvm_threads_states_threads gauge 190 | jvm_threads_states_threads{state="runnable",} 6.0 191 | jvm_threads_states_threads{state="blocked",} 0.0 192 | jvm_threads_states_threads{state="waiting",} 12.0 193 | jvm_threads_states_threads{state="timed-waiting",} 2.0 194 | jvm_threads_states_threads{state="new",} 0.0 195 | jvm_threads_states_threads{state="terminated",} 0.0 196 | # HELP system_cpu_usage The "recent cpu usage" for the whole system 197 | # TYPE system_cpu_usage gauge 198 | system_cpu_usage 0.004398821266581523 199 | # HELP jvm_gc_max_data_size_bytes Max size of old generation memory pool 200 | # TYPE jvm_gc_max_data_size_bytes gauge 201 | jvm_gc_max_data_size_bytes 5.48339712E9 202 | # HELP jvm_buffer_total_capacity_bytes An estimate of the total capacity of the buffers in this pool 203 | # TYPE jvm_buffer_total_capacity_bytes gauge 204 | jvm_buffer_total_capacity_bytes{id="direct",} 90112.0 205 | jvm_buffer_total_capacity_bytes{id="mapped",} 0.0 206 | # HELP tomcat_threads_config_max_threads 207 | # TYPE tomcat_threads_config_max_threads gauge 208 | tomcat_threads_config_max_threads{name="http-nio-8080",} 200.0 209 | # HELP jvm_buffer_count_buffers An estimate of the number of buffers in the pool 210 | # TYPE jvm_buffer_count_buffers gauge 211 | jvm_buffer_count_buffers{id="direct",} 11.0 212 | jvm_buffer_count_buffers{id="mapped",} 0.0 213 | # HELP tomcat_global_sent_bytes_total 214 | # TYPE tomcat_global_sent_bytes_total counter 215 | tomcat_global_sent_bytes_total{name="http-nio-8080",} 314.0 216 | # HELP tomcat_global_request_seconds 217 | # TYPE tomcat_global_request_seconds summary 218 | tomcat_global_request_seconds_count{name="http-nio-8080",} 4.0 219 | tomcat_global_request_seconds_sum{name="http-nio-8080",} 0.123 220 | ``` 221 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------