Re: [squid-users] helper output in logs

From: Alfredo Rezinovsky <alfrenovsky_at_gmail.com>
Date: Sun, 04 Aug 2013 17:22:19 -0300

El 04/08/13 15:52, Eliezer Croitoru escribió:
> On 08/04/2013 09:46 PM, Alfredo Rezinovsky wrote:
>> El 02/08/13 18:03, Amos Jeffries escribió:
>>> On 3/08/2013 3:37 a.m., Alfredo Rezinovsky wrote:
>>>> I'm using store_id_program and I want my program to ouput a Key/Value
>>>> pair so the value goes in the logs
>>>>
>>>> I tried with "log" and "tag" keys and using "%[et" and "%[ea" in
>>>> LogFormat but it didn't worked.
>>>>
>>>> There's a generic Key/Value handling or each helper needs a special
>>>> support ?
>>> See the new %note token. The intention is to make the keys sent back
>>> available as annotations, including custom ones from any helper.
>>> It is not quite working for all helpers yet (assistance with that
>>> welcome), but should be working for the store-ID ones.
>>>
>> The "%{my_key}note" in logformat worked exactly as I wanted.
>> It does work with store-id keys
>>
>> Thanks.
>>
>>
> Can you share the squid.conf output??
> So others can see how it's being done properly?
>
I'm trying to make a store_id_program with many plugins.

My store_id_program outputs

   OK store-id="http://STOREID/.... whatever ..." store-id-plugin="youtube"
   OK store-id="http://STOREID/.... whatever ..." store-id-plugin="vimeo"
   OK store-id="http://STOREID/.... whatever ..."
store-id-plugin="facebookimages"

I wanted the store-id-plugin to appear in the logs so I can make per
plugin statistics.

I dont need user name in the logs and I want to keep my logs as standard
as possible so I replaced "%[un" with "%[{store-id-plugin}note" in
LogFormat configuration.

My logformat in squid.conf:

   logformat access %ts.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru
%[{store-id-plugin}note %Sh/%<a %mt

Now I have the store-id-plugin name (or a "-" if no plugin) in the logs.
Here's two log line samples:

1375644685.928 2211 127.0.0.1 TCP_MISS/200 3438 GET
http://profile.ak.fbcdn.net/hprofile-ak-prn2/00000_000000000000000_000000000_q.jpg
facebookimages HIER_DIRECT/209.0.0.1 image/jpeg
1375647306.276 1628 127.0.0.1 TCP_MISS/200 2763 GET
http://query.yahooapis.com/v1/public/yql? - HIER_DIRECT/98.99.100.101
application/json

You can try %notes in LogFormat and will see a long string containing
ALL THE KEY-VALUE pairs in your logs.

(Some values were masked for privacy)

--
Alfrenovsky
Received on Sun Aug 04 2013 - 20:22:33 MDT

This archive was generated by hypermail 2.2.0 : Mon Aug 05 2013 - 12:00:17 MDT