Maven项目打包的方式有多种,我常用的就是使用assembly
的方式进行打包。
1 首先需要在pom项目中加入如下依赖
1 | ... |
2 使用如下命令进行编译打包
1 | mvn assembly:assembly |
Maven项目打包的方式有多种,我常用的就是使用assembly
的方式进行打包。
1 | ... |
1 | mvn assembly:assembly |
1 | log_format data_log '$remote_addr - $remote_user [$time_local] ' |
通过$http_cookie
就可以将请求的全部cookie获得。
输出单个cookie也很简单,只需要为cookie key加上$cookie_
前缀就可以了,例如有一个cookie的key为_tracker_user_id_
,那么在nginx中可以通过$cookie__tracker_user_id_
就可以获取到了。1
2
3
4
5log_format data_log '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $cookie_C_I $http_x_forwarded_for'
'"$cookie__tracker_user_id_"'
'"$upstream_addr" "$upstream_status" "$upstream_response_time" "$request_time"';
wget https://github.com/yahoo/CMAK/releases/download/3.0.0.5/cmak-3.0.0.5.zip
unzip cmak-3.0.0.5.zip
cmak.zkhosts=”hadoop101.eqxiu.com:2181” 改为真实的zk地址
wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz
tar -zxvf openjdk-11+28_linux-x64_bin.tar.gz
在文件的最上边加上JAVA_HOME的路径,比如:1
JAVA_HOME=/data/software/jdk-11
1 | ./bin/cmak -Dhttp.port=10010 |
1 | http://your-ip-address:10010 |
参考
https://github.com/yahoo/CMAK
https://cloud.tencent.com/developer/article/1651137
安装依赖1
2
3
4pip install sasl
pip install thrift
pip install thrift-sasl
pip install PyHive
python脚本示例1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from pyhive import hive
HOST="127.0.0.1"
PORT=10000
USERNAME="hadoop"
DATABASE="default"
conn=hive.Connection(host=HOST, port=PORT, username=USERNAME,database=DATABASE)
cursor = conn.cursor()
#cursor.execute("INSERT INTO TABLE test_out(name,count,time) SELECT name,count(1),to_date(time) FROM test GROUP BY name,to_date(time)")
cursor.execute("SELECT * FROM test")
for result in cursor.fetchall():
print(result[2])
请求日志中有很多的404 HEAD请求,为了将这部分日志过滤掉,修改了一下tornado请求日志的逻辑。
代码如下:
自定义请求日志的处理逻辑1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19# 日志消息格式
def log_request(handler):
if handler.get_status() < 400:
log_method = tornado.web.access_log.info
elif handler.get_status() < 500:
log_method = tornado.web.access_log.info
else:
log_method = tornado.web.access_log.info
request_time = 1000.0 * handler.request.request_time()
request_status = handler.get_status()
request_method = handler.request.method
# log_method("HH status={} method={}".format(request_status, request_method ))
if request_status == 404 and request_method == 'HEAD':
#不输出日志
pass
else:
log_method("%s|%d|%s|%.2f|%s",datetime.datetime.now(), request_status , handler._request_summary(), request_time, handler.request.headers.get("User-Agent", ""))
设置为Application.settings的log_function属性1
app.settings["log_function"] = log_request
最后输出的日志格式:
首先明确一点:Nginx的location不能否匹配到问号后的参数。参考https://www.zhihu.com/question/50190510
所以通过在location中的if条件来进行逻辑判断
1 | location /p.gif { |
url匹配规则 参考https://www.cnblogs.com/woshimrf/p/nginx-config-location.html1
2
3
4
5
6
7
8location [=|~|~*|^~|@] /uri/ {
...
}
= : 表示精确匹配后面的url
~ : 表示正则匹配,但是区分大小写
~* : 正则匹配,不区分大小写
^~ : 表示普通字符匹配,如果该选项匹配,只匹配该选项,不匹配别的选项,一般用来匹配目录
@ : "@" 定义一个命名的 location,使用在内部定向时,例如 error_page
作为linux中最为常用的三大文本(awk,sed,grep)处理工具之一,掌握好其用法是很有必要的。
grep家族总共有三个:grep,egrep,fgrep。
常用选项:1
2
3
4
5
6
7
8
9
10
11 -E :开启扩展(Extend)的正则表达式。
-i :忽略大小写(ignore case)。
-v :反过来(invert),只打印没有匹配的,而匹配的反而不打印。
-n :显示行号
-w :被匹配的文本只能是单词,而不能是单词中的某一部分,如文本中有liker,而我搜寻的只是like,就可以使用-w选项来避免匹配liker
-c :显示总共有多少行被匹配到了,而不是显示被匹配到的内容,注意如果同时使用-cv选项是显示有多少行没有被匹配到。
-o :只显示被模式匹配到的字符串。
--color :将匹配到的内容以颜色高亮显示。
-A n:显示匹配到的字符串所在的行及其后n行,after
-B n:显示匹配到的字符串所在的行及其前n行,before
-C n:显示匹配到的字符串所在的行及其前后各n行,context
本文只是对腾讯云COS文档的基本操作做了简单的介绍,具体的更详细的内容参考腾讯云官方链接。
其实还有一点,腾讯云文档中可能也有一些错误的地方,本文中对其做了调整。比如下边代码中的region
,应该是ap-加上地域的拼音,但是文档中给的却是COS_REGION,容易让人误解。
安装SDK依赖,其他安装方式见腾讯云官方链接。1
pip install -U cos-python-sdk-v5
1 | # -*- coding=utf-8 |
腾讯云”存储痛管理”中的”所属地区”中为中文,在程序里可能需要改写为拼音的大写形式
比如1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17# -*- coding=utf-8
# appid 已在配置中移除,请在参数 Bucket 中带上 appid。Bucket 由 BucketName-APPID 组成
# 1. 设置用户配置, 包括 secretId,secretKey 以及 Region
from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
import sys
import logging
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
secret_id = 'dsddOHuGL8fwwCFDFSMvEG3Z' # 替换为用户的 secretId(登录访问管理控制台获取)
secret_key = 'xxxEZfU2JL8etrYy7yZuy' # 替换为用户的 secretKey(登录访问管理控制台获取)
region = 'ap-beijing' # 替换为用户的 Region ,腾讯云"存储痛管理"中的"所属地区"中为中文,在这里需要改写为拼音的形式,并且使用ap-前缀
token = None # 使用临时密钥需要传入 Token,默认为空,可不填
scheme = 'https' # 指定使用 http/https 协议来访问 COS,默认为 https,可不填
config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token, Scheme=scheme)
# 2. 获取客户端对象
client = CosS3Client(config)
# 参照下文的描述。或者参照 Demo 程序,详见 https://github.com/tencentyun/cos-python-sdk-v5/blob/master/qcloud_cos/demo.py
有一种比较成熟的热图技术heatmap.js,通过不同的颜色来标记不同位置(页面上的坐标点)的访问频率,但是不能够标识出页面上某个元素,比如链接,图片的点击次数。
官网地址https://www.patrick-wied.at/static/heatmapjs/
git地址https://github.com/pa7/heatmap.js
使用demo参考 https://blog.csdn.net/Jermyo/article/details/110561098
给当前页面的window对象添加一个事件监听器。
在用户点击的时候,上报被点击元素的信息(主要包括url和element path等)。
在展示的时候,计算每个节点的点击PV和UV,并通过元素outline的宽度展示元素的点击量,当鼠标移动到某个元素上时,会出现tip提示框,显示具体的PV和UV数据。1
2
3window.addEventListener("click", function(e){
console.log(e.target.tagName);
});