@@ -136,6 +136,33 @@ func sendWebhook(amo *alertManOut) {
136136 }
137137}
138138
139+ func sendRawPromAlertWarn () {
140+ badString := `This program is suppose to be fed by alertmanager.` + "\n " +
141+ `It is not a replacement for alertmanager, it is a ` + "\n " +
142+ `webhook target for it. Please read the README.md ` + "\n " +
143+ `for guidance on how to configure it for alertmanager` + "\n " +
144+ `or https://prometheus.io/docs/alerting/latest/configuration/#webhook_config`
145+
146+ log .Print (`/!\ -- You have misconfigured this software -- /!\` )
147+ log .Print (`--- -- -- ---` )
148+ log .Print (badString )
149+
150+ DO := discordOut {
151+ Content : "" ,
152+ Embeds : []discordEmbed {
153+ {
154+ Title : "You have misconfigured this software" ,
155+ Description : badString ,
156+ Color : ColorGrey ,
157+ Fields : []discordEmbedField {},
158+ },
159+ },
160+ }
161+
162+ DOD , _ := json .Marshal (DO )
163+ http .Post (* whURL , "application/json" , bytes .NewReader (DOD ))
164+ }
165+
139166func main () {
140167 flag .Parse ()
141168 checkWhURL (* whURL )
@@ -157,30 +184,7 @@ func main() {
157184 err = json .Unmarshal (b , & amo )
158185 if err != nil {
159186 if isRawPromAlert (b ) {
160- badString := `This program is suppose to be fed by alertmanager.` + "\n " +
161- `It is not a replacement for alertmanager, it is a ` + "\n " +
162- `webhook target for it. Please read the README.md ` + "\n " +
163- `for guidance on how to configure it for alertmanager` + "\n " +
164- `or https://prometheus.io/docs/alerting/latest/configuration/#webhook_config`
165-
166- log .Print (`/!\ -- You have misconfigured this software -- /!\` )
167- log .Print (`--- -- -- ---` )
168- log .Print (badString )
169-
170- DO := discordOut {
171- Content : "" ,
172- Embeds : []discordEmbed {
173- {
174- Title : "You have misconfigured this software" ,
175- Description : badString ,
176- Color : ColorGrey ,
177- Fields : []discordEmbedField {},
178- },
179- },
180- }
181-
182- DOD , _ := json .Marshal (DO )
183- http .Post (* whURL , "application/json" , bytes .NewReader (DOD ))
187+ sendRawPromAlertWarn ()
184188 return
185189 }
186190
@@ -193,6 +197,7 @@ func main() {
193197
194198 return
195199 }
200+
196201 sendWebhook (& amo )
197202 }))
198203}
0 commit comments