如何获取整数列并根据范围分配字符串值

时间:2018-01-25 00:10:33

标签: splunk

我是一个splunk新手,希望获取一列int值,并根据它们所在的范围显示为字符串。

I.e.
Ints from 1-100 should display: Low 
Ints from 101-200 should display: Medium 
Ints from 201-300 should display: High

我相信我可以使用eval语句来完成此任务,但我不确定从那里开始。我怎么做到这一点?

1 个答案:

答案 0 :(得分:1)

最简单的方法可能是将其变成案例陈述:

| eval "new_column" = case (
    variable_evaluating >= 1 AND variable_evaluating <= 100, "Low",
    variable_evaluating >= 101 AND variable_evaluating <= 200, "Medium", 
    variable_evaluating >= 201, "High")