sipcapture / homer

HOMER - 100% Open-Source SIP, VoIP, RTC Packet Capture & Monitoring
https://sipcapture.org
GNU Affero General Public License v3.0
1.61k stars 240 forks source link

Searching in custom headers in Homer 7 web GUI #484

Closed solarmon closed 3 years ago

solarmon commented 3 years ago

Hi,

As discussed in the Gitter channel, I would like to figure out how I can configure the Homer 7 web GUI to allow me to search based on custom headers.

Please note that my Homer 7 setup is from https://github.com/sipcapture/homer7-docker so this may important when talking about where configurations are.

On the Gitter channel I was given some links, but I was struggling to understand how to put it all together:

https://github.com/sipcapture/homer-app/wiki/Examples:-Correlation-MAPPING#correlation-id-correlation---graphing-all-calls-with-the-same-correlation-id- https://github.com/sipcapture/heplify-server/blob/master/example/homer7_config/heplify-server.toml#L64

In this example, I want to be able to search on a custom header call "X-Homer-Search".

This is what I have done so far:

- "HEPLIFYSERVER_CUSTOMHEADER=[\"X-Homer-Search\"]"

HEPLIFYSERVER_CUSTOMHEADER=["X-Homer-Search"]

{
        "id": "protocol_header.CustomHeader",
        "name": "X-Homer-Search",
        "type": "string",
        "index": "none",
        "form_type": "input",
        "position": 24,
        "skip": false,
        "hide": true,
        "sid_type": true
    }

Please advise what I am doing wrong, or if there is any other steps or checks I should/could do.

Thank you.

solarmon commented 3 years ago

The X-Homer-Search header is shown in the parsed SIP headers for the INVITE: image

If I try to search for 'blank' in the search form using the "X-Homer-Search" field, it does not return any results:

image

adubovikov commented 3 years ago

"sid_type": true

should be removed.

solarmon commented 3 years ago

I have removed it, and I also tried setting 'hide' to false:

 {
        "id": "protocol_header.CustomHeader",
        "name": "X-Homer-Search",
        "type": "string",
        "index": "none",
        "form_type": "input",
        "position": 24,
        "skip": false,
        "hide": false
    }

But this did not seem to make any difference.

adubovikov commented 3 years ago

please go to Details tab and show us the all records what you can see.

homer-7-9-14-prod-

solarmon commented 3 years ago

In the Details tab, I don't see the custom header:

image

adubovikov commented 3 years ago

this means it has been not extracted. You have to check your heplify-server.toml

solarmon commented 3 years ago

Where do I check that? As stated already, this Homer 7 setup is built using https://github.com/sipcapture/homer7-docker and I've only had to configure/edit the docker-compose.yml file.

I can get in to the heplify-server docker image, but where is the heplify-server.toml file?

My understanding is that in this docker based setup it will use the environment variables for the configuration? If I check the environment variables on the heplify-server docker image, I do see:

HEPLIFYSERVER_CUSTOMHEADER=["X-Homer-Search"]

image

adubovikov commented 3 years ago

@lmangani I am not sure, but will be this env param converted to CustomHeader ?

https://github.com/sipcapture/heplify-server/blob/master/example/homer7_config/heplify-server.toml#L64

lmangani commented 3 years ago

Try the following instead, since its a single value:

 - "HEPLIFYSERVER_CUSTOMHEADER=X-Homer-Search"
solarmon commented 3 years ago

Try the following instead, since its a single value:

 - "HEPLIFYSERVER_CUSTOMHEADER=X-Homer-Search"

The example was just with a single header just to do a proof of concept. Potentially I would want to search on multiple custom headers.

Anyway, I did as suggested, and reloaded heplify-server with docker-compose up -d but I still don't see the header in the Details tab.

How can I check on the heplify-server docker image, other than the environment variables, what configuration it is using? How can we be sure that HEPLIFYSERVER_CUSTOMHEADER is converted to CustomHeader and used by heplify-server?

adubovikov commented 3 years ago

so, found. This is multiconfig and it should proceed without any problem

https://github.com/negbie/multiconfig/blob/master/env.go#L55

@solarmon can you run heplify-server without docker just to be sure that it parses everything that you need ?

lmangani commented 3 years ago

uppercase(parameter) = ENV and it should work just fine with a single value or an array.

Your next option is to create a custom .toml config file and mount it on the image instead of using the ENV variables.

solarmon commented 3 years ago

In my last comment, I was looking at an existing SIP INVITE. I made a new call, the I actually do now see the header listed in Details:

image

(I will have to revert to original format, and check with new calls, but I thought I did look at new calls).

That's definitely a step forward! But the search still does not seem to work.

solarmon commented 3 years ago

So I did a bit more testing, and I can get it to show more than one custom header in Details:

image

I used the following in docker-compose.yml:

      - "HEPLIFYSERVER_CUSTOMHEADER=X-Homer-Search,X-Homer-Search2"

So, I didn't have to use the brackets, or quote marks.

solarmon commented 3 years ago

But I still can't figure out how to get it to search on these custom headers.

adubovikov commented 3 years ago

great. Now can you please see which sql query your search generated ?

adubovikov commented 3 years ago

your ID should be data_header.X-Homer-Search

 {
        "id": "data_header.X-Homer-Search",
        "name": "X-Homer-Search",
        "type": "string",
        "index": "none",
        "form_type": "input",
        "position": 24,
        "skip": false,
        "hide": false
    }
solarmon commented 3 years ago

OK, I changed it to what you have suggested.

image

Initially, it didn't seem to work.

When I looked at the search settings it was like:

image

I pressed 'Save' and it presented the correct Active list, and I selected and made 'X-Homer-Search' Active.

Now the search is working!

image

Thank you so much. Now I've got the correct steps and configuration to add other custom headers for searching.

adubovikov commented 3 years ago

Perfect! Now time for payback! :-) Can you please document it and we will add it to WIKI ? ;-)

solarmon commented 3 years ago

Hi. I have created my own notes in Evernote. I'm not sure whether it is good enough for you to use in your Wiki, but it is here:

https://www.evernote.com/shard/s13/sh/2441ffbc-a7fa-2d5b-ef39-f2775b8fbb7f/7198abc3c01c44a391184717caa5daea

adubovikov commented 3 years ago

Thank you so much! We will work on it!