-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from jshaughn/hawkular-1328
Hawkular 1328. Support both live-metrics and live-alerting. Prometheus support.
- Loading branch information
Showing
171 changed files
with
5,109 additions
and
4,504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
require 'hawkular/base_client' | ||
require 'hawkular/inventory/entities' | ||
require 'ostruct' | ||
|
||
module Hawkular::Prometheus | ||
class Alerter < Hawkular::BaseClient | ||
def initialize(entrypoint, credentials = {}, options = {}) | ||
@entrypoint = normalize_entrypoint_url entrypoint, 'hawkular/alerter' | ||
super(@entrypoint, credentials, options) | ||
end | ||
|
||
def prometheus_entrypoint | ||
rest_client('/prometheus/endpoint').get | ||
end | ||
end | ||
|
||
# Interface to talk with the Prometheus server used for Middleware Manager | ||
# @param entrypoint [String] base url of Hawkular Services | ||
class Client < Hawkular::BaseClient | ||
def initialize(entrypoint, credentials = {}, options = {}) | ||
prometheus_entrypoint = Alerter.new(entrypoint, credentials, options).prometheus_entrypoint | ||
@entrypoint = normalize_entrypoint_url prometheus_entrypoint, 'api/v1' | ||
super(@entrypoint, credentials, options) | ||
end | ||
|
||
def query(metrics: [], time: nil) | ||
results = [] | ||
metrics.each do |metric| | ||
query = metric['expression'] | ||
response = http_get "/query?start=#{time}&query=#{query}" | ||
result = response['data']['result'].empty? ? {} : response['data']['result'].first | ||
result['metric'] = metric | ||
results << result | ||
end | ||
results | ||
end | ||
|
||
def query_range(metrics: [], starts: nil, ends: nil, step: nil) | ||
results = [] | ||
metrics.each do |metric| | ||
query = metric['expression'] | ||
response = http_get "/query_range?start=#{starts}&end=#{ends}&step=#{step}&query=#{query}" | ||
result = response['data']['result'].empty? ? {} : response['data']['result'].first | ||
result['metric'] = metric | ||
results << result | ||
end | ||
results | ||
end | ||
|
||
def up_time(feed_id: nil, starts: nil, ends: nil, step: nil) | ||
query = "up{feed_id=\"#{feed_id}\"}" | ||
response = http_get "/query_range?start=#{starts}&end=#{ends}&step=#{step}&query=#{query}" | ||
if response['data']['result'].empty? | ||
[] | ||
else | ||
response['data']['result'].first['values'] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -732,7 +732,8 @@ module Hawkular::Alerts::RSpec | |
@client = Hawkular::Alerts::Client.new(ALERTS_BASE, creds, options) | ||
end | ||
|
||
it 'Should create and fire a trigger' do | ||
# FIXME: disabled because involves hawkular-metrics | ||
xit 'Should create and fire a trigger' do | ||
email_props = { to: '[email protected]', | ||
from: '[email protected]' } | ||
begin | ||
|
Oops, something went wrong.