mirror of
				https://github.com/louislam/uptime-kuma.git
				synced 2025-10-31 03:19:20 +08:00 
			
		
		
		
	Change casing in README, apply DRY to label values
This commit is contained in:
		
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							| @@ -95,14 +95,14 @@ Labels to filter by include: | ||||
| | Label Name | Description | | ||||
| +------------+-------------+ | ||||
| |monitor_name| The "Friendly Name" of the monitor | | ||||
| |monitor_type| The type (http, keyword, tcp) of monitoring check | | ||||
| |monitor_url | The URL to be monitored (http, keyword) | ||||
| |monitor_hostname | The Hostname to be monitored (tcp) | | ||||
| |monitor_port | The port to be monitored (tcp) | | ||||
| |monitor_type| The type (HTTP, keyword, TCP) of monitoring check | | ||||
| |monitor_url | The URL to be monitored (HTTP, keyword) | ||||
| |monitor_hostname | The Hostname to be monitored (TCP) | | ||||
| |monitor_port | The port to be monitored (TCP) | | ||||
|  | ||||
| ## Example PromQL queries | ||||
|  | ||||
| Assuming we have http monitors in place for bbc.co.uk and google.com: | ||||
| Assuming we have HTTP monitors in place for bbc.co.uk and google.com: | ||||
|  | ||||
| ``` | ||||
| # Show all response rates gouped by site | ||||
|   | ||||
| @@ -18,6 +18,7 @@ const commonLabels = [ | ||||
|     'monitor_port', | ||||
| ] | ||||
|  | ||||
|  | ||||
| const monitor_response_time = new Prometheus.Gauge({ | ||||
|     name: 'monitor_response_time', | ||||
|     help: 'Monitor Response Time (ms)', | ||||
| @@ -65,6 +66,15 @@ class Monitor extends BeanModel { | ||||
|     start(io) { | ||||
|         let previousBeat = null; | ||||
|  | ||||
|         const monitorLabelValues = { | ||||
|                 monitor_name: this.name, | ||||
|                 monitor_type: this.type, | ||||
|                 monitor_url: this.url, | ||||
|                 monitor_hostname: this.hostname, | ||||
|                 monitor_port: this.port | ||||
|         } | ||||
|  | ||||
|  | ||||
|         const beat = async () => { | ||||
|             if (! previousBeat) { | ||||
|                 previousBeat = await R.findOne("heartbeat", " monitor_id = ? ORDER BY time DESC", [ | ||||
| @@ -162,13 +172,7 @@ class Monitor extends BeanModel { | ||||
|             } | ||||
|  | ||||
|  | ||||
|             monitor_status.set({ | ||||
|                 monitor_name: this.name, | ||||
|                 monitor_type: this.type, | ||||
|                 monitor_url: this.url, | ||||
|                 monitor_hostname: this.hostname, | ||||
|                 monitor_port: this.port | ||||
|             }, bean.status) | ||||
|             monitor_status.set(monitorLabelValues, bean.status) | ||||
|  | ||||
|             if (bean.status === 1) { | ||||
|                 console.info(`Monitor #${this.id} '${this.name}': Successful Response: ${bean.ping} ms | Interval: ${this.interval} seconds | Type: ${this.type}`) | ||||
| @@ -176,13 +180,7 @@ class Monitor extends BeanModel { | ||||
|                 console.warn(`Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Type: ${this.type}`) | ||||
|             } | ||||
|  | ||||
|             monitor_response_time.set({ | ||||
|                 monitor_name: this.name, | ||||
|                 monitor_type: this.type, | ||||
|                 monitor_url: this.url, | ||||
|                 monitor_hostname: this.hostname, | ||||
|                 monitor_port: this.port | ||||
|             }, bean.ping) | ||||
|             monitor_response_time.set(monitorLabelValues, bean.ping) | ||||
|  | ||||
|             io.to(this.user_id).emit("heartbeat", bean.toJSON()); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user