|  | @@ -3,7 +3,9 @@ package alert
 | 
	
		
			
			| 3 | 3 |  import (
 | 
	
		
			
			| 4 | 4 |  	"bytes"
 | 
	
		
			
			| 5 | 5 |  	"encoding/json"
 | 
	
		
			
			|  | 6 | +	"fmt"
 | 
	
		
			
			| 6 | 7 |  	"net/http"
 | 
	
		
			
			|  | 8 | +	"strconv"
 | 
	
		
			
			| 7 | 9 |  
 | 
	
		
			
			| 8 | 10 |  	"metrics-alerting/config"
 | 
	
		
			
			| 9 | 11 |  )
 | 
	
	
		
			
			|  | @@ -14,9 +16,17 @@ type alertBody struct {
 | 
	
		
			
			| 14 | 16 |  }
 | 
	
		
			
			| 15 | 17 |  
 | 
	
		
			
			| 16 | 18 |  func alertHttp(script config.Script, result interface{}) error {
 | 
	
		
			
			|  | 19 | +	var value string
 | 
	
		
			
			|  | 20 | +	switch script.Type {
 | 
	
		
			
			|  | 21 | +	case "number":
 | 
	
		
			
			|  | 22 | +		value = strconv.FormatFloat(result.(float64), 'e', -1, 64)
 | 
	
		
			
			|  | 23 | +	case "bool":
 | 
	
		
			
			|  | 24 | +		value = strconv.FormatBool(result.(bool))
 | 
	
		
			
			|  | 25 | +	}
 | 
	
		
			
			|  | 26 | +
 | 
	
		
			
			| 17 | 27 |  	alert := alertBody{
 | 
	
		
			
			| 18 | 28 |  		Key:   script.Key,
 | 
	
		
			
			| 19 |  | -		Value: result,
 | 
	
		
			
			|  | 29 | +		Value: value,
 | 
	
		
			
			| 20 | 30 |  	}
 | 
	
		
			
			| 21 | 31 |  
 | 
	
		
			
			| 22 | 32 |  	body, err := json.Marshal(alert)
 | 
	
	
		
			
			|  | @@ -35,7 +45,7 @@ func alertHttp(script config.Script, result interface{}) error {
 | 
	
		
			
			| 35 | 45 |  
 | 
	
		
			
			| 36 | 46 |  	if resp.StatusCode != http.StatusOK {
 | 
	
		
			
			| 37 | 47 |  		return fmt.Errorf(
 | 
	
		
			
			| 38 |  | -			"target %s returned non-200 status code %d", script.Target, resp.StatusCode
 | 
	
		
			
			|  | 48 | +			"target %s returned non-200 status code %d", script.Target, resp.StatusCode,
 | 
	
		
			
			| 39 | 49 |  		)
 | 
	
		
			
			| 40 | 50 |  	}
 | 
	
		
			
			| 41 | 51 |  
 |