代码之家  ›  专栏  ›  技术社区  ›  CW Holeman II

Apache访问日志的YQL表

  •  0
  • CW Holeman II  · 技术社区  · 17 年前

    YQL SHOW TABLES 有CSV和HTML。关于Apache访问日志的表呢?

    3 回复  |  直到 17 年前
        2
  •  0
  •   Sam Pullara    17 年前

    Apache日志实际上有一个可定制的格式,所以我假设您指的是通用日志格式或默认格式之一。如果我们添加类似的内容,那么很可能会有一个基于regex的行读取器,您可以将其应用于apache日志。谢谢你的建议。

        3
  •  0
  •   erik    16 年前

    <?xml version="1.0" encoding="UTF-8"?>
    <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
        <meta>
            <author></author>
            <sampleQuery>select * from {table}</sampleQuery>
        </meta>
        <bindings>
            <select itemPath="" produces="XML">
                <inputs>
                    <key id="url" type="xs:string" paramType="variable"/>
                </inputs>
                <execute><![CDATA[
    
                        //http://en.wikipedia.org/wiki/Common_Log_Format
                var entry = '208.240.243.170 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326';
    
                var names = ['IP', 'RFC 1413', 'userid', 'date', 'request', 'status', 'size'];
                var values = entry.split(' ');
    
                var resp = {};
    
                for (var i in names) {
                    var name = names[i];
                    resp[name] = values[i];
                }
    
                response.object = resp;
    
          ]]></execute>
            </select>
        </bindings>
    </table>
    

    您可以这样运行它: 使用“http://{your domain}/table.xml”作为表;从表中选择*

    然后,您可以扩展它,通过ip查找地理数据: