-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
External Logging link for container nodes #13704
External Logging link for container nodes #13704
Conversation
This depends on #13319 (I pulled over the commit from there, will rebase once its merged) |
app/models/container_node.rb
Outdated
@@ -79,4 +80,19 @@ def ipaddress | |||
def cockpit_url | |||
URI::HTTP.build(:host => ipaddress, :port => 9090) | |||
end | |||
|
|||
supports :common_logging do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I like the phrase "common logging" as that is a Red Hat idiom. cc @blomquisg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll answer on #13319
config/settings.yml
Outdated
@@ -80,6 +80,8 @@ | |||
:scan_via_host: true | |||
:use_vim_broker: true | |||
:use_vim_broker_ems: true | |||
:container_logging: | |||
:common_logging_route: logging-kibana-ops |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels wrong as a setting in the general settings...feels like it should a per-provider settings or perhaps a special endpoint on each provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ill answer on #13319
67db9e5
to
0144a88
Compare
I removed the commit from the parent PR so this will only be green after it is merged. |
This pull request is not mergeable. Please rebase and repush. |
@enoodle can you handle the rebase? |
0144a88
to
82b5cc3
Compare
6505533
to
fdf76bd
Compare
@enoodle, this looks like it tries to catch both hostnames and ManageIQ names. Ideally we'd have all logs from a given cluster tagged with a certain value in the " |
fdf76bd
to
d9c40c4
Compare
d9c40c4
to
a2dc0bc
Compare
@portante I changed to try the hostname from the kubernetes label first. I also changed to make the query itself easier to read. |
app/models/container_node.rb
Outdated
def external_logging_path | ||
hostname = (ipaddress || name || "").split('.').first | ||
query = "bool:(filter:(or:!((term:(hostname:#{hostname})),(term:(hostname:#{name})))))" | ||
"/#/discover?_g=()&_a=(columns:!(_source),filters:!((meta:(disabled:!f,index:'.operations.*',key:hostname,negate:!f),#{query})),index:'.operations.*',interval:auto,query:(query_string:(analyze_wildcard:!t,query:'*')),sort:!(time,desc))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you factor out the .operations.*
index name as a variable? It appears in two places in the string. Also, I tried to use this URL with a few adjustments for names in my Kibana instance, but I get an error. Are you sure this is right?
Additionally, could we add some fields by default so that it is not just the _source
field, which is large blob? Perhaps adding hostname
, level
, pod_name
, and message
would be sufficient initially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that this URL is right, but it is working for me (I have added a gif, made it for the UI Patch but it fits here too).
To get this URL I opened Kibana and told it to filter by hostname. I then changed the query to catch the both fqdn and hostname and trimmed it a little. This is where the _source
came from. To my understanding after playing with this a little this changes the columns that are displayed next to each message in the list. I will set this to the columns you suggested.
The field level
is empty for me on all messages but I assume that future improvments with the data model will change that.
app/models/container_node.rb
Outdated
|
||
supports :external_logging_support do | ||
unless ext_management_system.respond_to?(:external_logging_route_name) | ||
unsupported_reason_add(:external_logging_support, _('This provider type does not support external_logging_support')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this message from the department of the redundancy department? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will un-robotize this. This message is not for the end user though.
ff3c930
to
d4299b9
Compare
@enoodle, I'll try to get this URL working for me in my kibana instance and report back. |
d4299b9
to
f80a208
Compare
I made a simple python script to verify the base string works now. Looks good!
|
@simon3z I verified this with the latest update to the UI PR. updated the GIF. |
app/models/container_node.rb
Outdated
|
||
def external_logging_path | ||
fqdn = (ipaddress || name || "") | ||
hostname = fqdn.split('.').first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simon3z The name of the method was misleading so I changed it from ipaddress
to kubernetes_hostname
. If it is indeed returning an IP address instead of an hostname then we will add a search for the first octect (OR the full IP). It will not be optimal but won't crush anything and considering that none of our options gave a valid hostname it seems like an acceptable option.
I fixed hostname
to have a default value of ""
06a2dcc
to
2f2e527
Compare
app/models/container_node.rb
Outdated
def external_logging_path | ||
fqdn = (kubernetes_hostname || name || "") | ||
hostname = fqdn.split('.').first || "" | ||
query = "bool:(filter:(or:!((term:(hostname:'#{hostname}')),(term:(hostname:'#{fqdn}')))))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@enoodle I don't understand, why do you still use the hostname
here even if it's empty.
I have the feeling we should be smarter on how to build this query.
Implicitly I believe that what you're saying here is:
- if
fqdn
is empty (and thereforehostname
is empty), return all logs - if
hostname
is empty, just usefqdn
- use both
fqdn
andhostname
if available
Although I assume that the above relies on Kibana treating an empty string ""
as a search term not to consider.
I'd prefer to see all the logic expressed in code rather than relying on Kibana behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simon3z, unfortunately, the logging subsystem does not return a consistent set of hostnames for the same entity. So some parts of the logging subsystem gather the FQDN, other parts might use the shortened name. I believe this query is trying to account for that. We have to file bugs with the logging subsystem to fix the collectors to ensure an FQDN.
Having said that, data collection is never going to be perfect, so it is likely we'll need to keep this around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simon3z I want a query to get all the message with hostname that equals to the fqdn of the node OR the hostname of the node. This is derived from looking at the values of this field in the logs that are currently being collected.
I have tested that if either fqdn
or hostname
will be empty string ""
it will not add results to the search query results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested that if either fqdn or hostname will be empty string "" it will not add results to the search query results.
@enoodle as mentioned above I think this should be explicit in the logic that builds the query rather than implicit in the empty string handling of kibana.
2f2e527
to
cda3b14
Compare
@simon3z PTAL |
app/models/container_node.rb
Outdated
query = "#{query}," if !hostname.blank? && !fqdn.blank? | ||
query = "#{query}(term:(hostname:'#{hostname}'))" if !hostname.blank? | ||
query = "#{query})))" | ||
index = ".operations.*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@enoodle mmmm... logic is still incomplete because fqdn.split('.').first
could generate an hostname that is == fqdn
:
fqdn = "node_short_hostname"
hostname = fqdn.split('.').first || ""
=> "node_short_hostname"
Also you check multiple times (at least 4) for !fqdn.blank?
and !hostname.blank?
Since this search is term-based couldn't you just do something like:
node_hostnames = [kubernetes_hostname || name] # node name cannot be empty, it's an ID
node_hostnames.push(node_hostnames.first.split('.').first)
node_hostnames_query = node_hostnames.uniq.map{|x| "(term:(hostname:'#{x}'))"}.join(",")
...
Which for test.example.com
would generate a node_hostnames_query = "(term:(hostname:'test.example.com')),(term:(hostname:'test'))"
Also it seems that the URL may deserve a constant.
cda3b14
to
9a08f62
Compare
it "queries only for the name/fqdn when hostname can't be parsed" do | ||
node = FactoryGirl.create(:container_node, :name => "hello") | ||
query = get_query(node.external_logging_path) | ||
expect(query).to eq("bool:(filter:(or:!((term:(hostname:'hello')),(term:(hostname:'hello')))))") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@enoodle shouldn't this fail now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simon3z Yes, I am on it. This is not working as intended yet.
9a08f62
to
fccc487
Compare
@simon3z PTAL |
@enoodle please add a test that takes advantage of |
fccc487
to
9fcafb0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@miq-bot assign Fryguy
@miq-bot assign Fryguy |
end | ||
|
||
def evaluate_alert(_alert_id, _event) | ||
# currently only EmsEvents from hawkular are tested for node alerts, | ||
# and these should automaticaly be translated to alerts. | ||
true | ||
end | ||
|
||
supports :external_logging_support do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is funny because it duplicates the word support in certain caller paths. I think you just want supports :external_logging
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, do you want me to change this name in this PR? This will involve changing it in "app/models/mixins/support_feature_mixin.rb" and "app/models/manageiq/providers/container_manager.rb" too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opt for changing it 👍 But in it's own PR - and check if the UI depends on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't realize it wasn't introduced in this PR. Yeah, then separate PR for sure.
app/models/container_node.rb
Outdated
|
||
supports :external_logging_support do | ||
unless ext_management_system.respond_to?(:external_logging_route_name) | ||
unsupported_reason_add(:external_logging_support, _('This provider type does not support Extrenal Logging')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo Extrenal
-> External
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to make this a dynamic supports method? Why not just supports_not :external_logging
. @durandom Thoughts here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fryguy This is for the Kubernetes container provider. It doesn't use routes so it can't support this feature.
describe "#external_logging_path" do | ||
def get_query(path) | ||
index = ".operations.*" | ||
prefix_len = "/#/discover?_g=()&_a=(columns:!(hostname,level,kubernetes.pod_name,message),filters:!((meta:(disabled:!f,index:'#{index}',key:hostname,negate:!f),".length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels wrong to duplicate this string in the test. Is there a way to keep it in the model? Perhaps a pair of methods for constructing and desconstructing the query string in the model?
9729627
to
a3bc353
Compare
container node ipaddress rename to kubernetes_hostname the previous name, "ipaddress" is confusing and does not reflect well on the return value.
a3bc353
to
c025dcd
Compare
Checked commit enoodle@c025dcd with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Adding the common logging link support for container nodes.