mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
Add error propagation to web UI via special JSON error type.
This commit is contained in:
parent
49c87348b5
commit
1760d927c8
|
@ -132,10 +132,10 @@ func (matrix Matrix) ToString() string {
|
||||||
func ErrorToJSON(err error) string {
|
func ErrorToJSON(err error) string {
|
||||||
errorStruct := struct {
|
errorStruct := struct {
|
||||||
Type string
|
Type string
|
||||||
Error string
|
Value string
|
||||||
}{
|
}{
|
||||||
Type: "error",
|
Type: "error",
|
||||||
Error: err.Error(),
|
Value: err.Error(),
|
||||||
}
|
}
|
||||||
|
|
||||||
errorJSON, err := json.MarshalIndent(errorStruct, "", "\t")
|
errorJSON, err := json.MarshalIndent(errorStruct, "", "\t")
|
||||||
|
|
|
@ -84,6 +84,10 @@ function submitQuery() {
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: form.serialize(),
|
data: form.serialize(),
|
||||||
success: function(json, textStatus) {
|
success: function(json, textStatus) {
|
||||||
|
if (json.Type == "error") {
|
||||||
|
alert(json.Value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
data = transformData(json);
|
data = transformData(json);
|
||||||
if (data.length == 0) {
|
if (data.length == 0) {
|
||||||
alert("No datapoints found.");
|
alert("No datapoints found.");
|
||||||
|
|
Loading…
Reference in a new issue