在AWS Cloudwatch中,我想从日志数据中提取值。但是值在消息字段中。无论如何我可以抓住最后一个空格分隔值并记录下来吗?
即。我的日志流:
{"timestamp": 145674445, "message": "Starting new HTTP connection (1): XXXX", "severity": "INFO", "module": "connectionpool", "stack": []}
{"timestamp": 145676445, "message": "Starting new HTTP connection (1): XXXX", "severity": "INFO", "module": "connectionpool", "stack": []}
{"timestamp": 145676445, "message": "deactivated campaign: XXXX05XXXX554aaXXXX9069d4XXXXe7, runtime: 2.63", "severity": "INFO", "module": "credentials", "stack": []}
对于最后一个日志,我想过滤像
这样的模式{($.message ="deactivated campaign:*, runtime: *")}
我希望能够将度量值I记录为2.63,或最后一个以空格分隔的字符串。
我正在使用GUI,但无法想出办法。可能吗?
非常感谢任何提前帮助!
答案 0 :(得分:0)
查看http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/FilterAndPatternSyntax.html
像这样的东西(没有测试过,但是沿着这些方向的东西):
import UIKit
class ProfileCreator: UIViewController, UIPickerViewDelegate, UITextFieldDelegate, UIPickerViewDataSource {
// -------------------------------------------------------------------------------------- //
// DOB Selector From Text Field Start 1 //
@IBOutlet weak var DOBSelectorTextField: UITextField!
func textFieldDidBeginEditing(textField: UITextField) {
let datepicker = UIDatePicker()
textField.inputView = datepicker
datepicker.datePickerMode = UIDatePickerMode.Date
datepicker.addTarget(self, action: "datepickerchanged:", forControlEvents: .ValueChanged)
}
func textFieldShouldReturn(textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
func datepickerchanged(sender: UIDatePicker) {
let formatter = NSDateFormatter()
formatter.dateFormat = "dd MMMM yyyy"
DOBSelectorTextField.text = formatter.stringFromDate(sender.date)
}
// DOB Selector From Text Field End 1 //
// -------------------------------------------------------------------------------------- //
// Gender Selector From Text Field Start 1 //
@IBOutlet weak var GenderSelectorTextField: UITextField!
var GenderSelectorData = ["Male", "Female"]
var GenderSelectorPicker = UIPickerView()
// Gender Selector From Text Field End 1 //
// -------------------------------------------------------------------------------------- //
// Height Whole Number Text Field Start 1 //
@IBOutlet weak var HeightWholeNumberTextField: UITextField!
// Height Whole Number Text Field Start 1 //
// -------------------------------------------------------------------------------------- //
// Height Whole Number Unit Selector Text Field Start 1 //
@IBOutlet weak var HeightWholeNumberUnitSelectorTextField: UITextField!
var HeightWholeNumberUnitSelectorData = ["m", "ft"]
var HeightWholeNumberUnitSelectorPicker = UIPickerView()
// Height Whole Number Unit Selector Text Field Start 1 //
// -------------------------------------------------------------------------------------- //
// Height Decimal Number Text Field Start 1 //
@IBOutlet weak var HeightDecimalTextField: UITextField!
// Height Decimal Number Text Field End 1 //
// -------------------------------------------------------------------------------------- //
// Height Decimal Number Unit Selector Text Field Start 1 //
@IBOutlet weak var HeightDecimalNumberUnitSelectorTextField: UITextField!
var HeightDecimalNumberUnitSelectorData = ["cm", "inch"]
var HeightDecimalNumberUnitSelectorPicker = UIPickerView()
// Height Decimal Number Unit Selector Text Field End 1 //
// -------------------------------------------------------------------------------------- //
// Current Weight Whole Number Text Field Start 1 //
@IBOutlet weak var CurrentWeightWholeNumberTextField: UITextField!
// Current Weight Whole Number Text Field Start 1 //
// -------------------------------------------------------------------------------------- //
// Current Weight Whole Number Unit Selector Text Field Start 1 //
@IBOutlet weak var CurrentWeightWholeNumberUnitSelectorTextField: UITextField!
var CurrentWeightWholeNumberUnitSelectorData = ["kg", "lb"]
var CurrentWeightWholeNumberUnitSelectorPicker = UIPickerView()
// Current Weight Whole Number Unit Selector Text Field Start 1 //
// -------------------------------------------------------------------------------------- //
// Current Weight Decimal Number Text Field Start 1 //
@IBOutlet weak var CurrentWeightDecimalNumberTextField: UITextField!
// Current Weight Decimal Number Text Field End 1 //
// -------------------------------------------------------------------------------------- //
// Current Weight Decimal Number Unit Selector Text Field Start 1 //
@IBOutlet weak var CurrentWeightDecimalNumberUnitSelectorTextField: UITextField!
var CurrentWeightDecimalNumberUnitSelectorData = ["g", "oz"]
var CurrentWeightDecimalNumberUnitSelectorPicker = UIPickerView()
// Current Weight Decimal Number Unit Selector Text Field End 1 //
// -------------------------------------------------------------------------------------- //
// Close keyboard start //
func closekeyboard() {
self.view.endEditing(true)
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
closekeyboard()
}
// Close keyboard end //
// -------------------------------------------------------------------------------------- //
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// -------------------------------------------------------------------------------------- //
// DOB Selector From Text Field Start 2 //
DOBSelectorTextField.delegate = self
// DOB Selector From Text Field End 2 //
// -------------------------------------------------------------------------------------- //
// Gender Selector From Text Field Start 2 //
GenderSelectorPicker.delegate = self
GenderSelectorPicker.dataSource = self
GenderSelectorTextField.inputView = GenderSelectorPicker
// Gender Selector From Text Field End 2 //
// -------------------------------------------------------------------------------------- //
// Height Whole Number Unit Selector Text Field Start 2 //
HeightWholeNumberUnitSelectorPicker.delegate = self
HeightWholeNumberUnitSelectorPicker.dataSource = self
HeightWholeNumberUnitSelectorTextField.inputView = HeightWholeNumberUnitSelectorPicker
// Height Whole Number Unit Selector Text Field End 2 //
// -------------------------------------------------------------------------------------- //
// Height Decimal Unit Selector Text Field Start 1 //
HeightDecimalNumberUnitSelectorPicker.delegate = self
HeightDecimalNumberUnitSelectorPicker.dataSource = self
HeightDecimalNumberUnitSelectorTextField.inputView = HeightDecimalNumberUnitSelectorPicker
// Height Decimal Unit Selector Text Field End 1 //
// -------------------------------------------------------------------------------------- //
// Current Weight Whole Number Unit Selector Text Field Start 2 //
CurrentWeightWholeNumberUnitSelectorPicker.delegate = self
CurrentWeightWholeNumberUnitSelectorPicker.dataSource = self
CurrentWeightWholeNumberUnitSelectorTextField.inputView = CurrentWeightWholeNumberUnitSelectorPicker
// Current Weight Whole Number Unit Selector Text Field End 2 //
// -------------------------------------------------------------------------------------- //
// Current Weight Decimal Unit Selector Text Field Start 1 //
CurrentWeightDecimalNumberUnitSelectorPicker.delegate = self
CurrentWeightDecimalNumberUnitSelectorPicker.dataSource = self
CurrentWeightDecimalNumberUnitSelectorTextField.inputView = CurrentWeightDecimalNumberUnitSelectorPicker
// Current Weight Decimal Unit Selector Text Field End 1 //
// -------------------------------------------------------------------------------------- //
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// -------------------------------------------------------------------------------------- //
// Selectors Start 1 //
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
if pickerView == GenderSelectorPicker {
return GenderSelectorData.count
} else if pickerView == HeightWholeNumberUnitSelectorPicker {
return HeightWholeNumberUnitSelectorData.count
} else if pickerView == HeightDecimalNumberUnitSelectorPicker {
return HeightDecimalNumberUnitSelectorData.count
} else if pickerView == CurrentWeightWholeNumberUnitSelectorPicker {
return CurrentWeightWholeNumberUnitSelectorData.count
} else if pickerView == CurrentWeightDecimalNumberUnitSelectorPicker {
return CurrentWeightDecimalNumberUnitSelectorData.count
}
return 1
}
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent comonent: Int) {
if pickerView == GenderSelectorPicker {
GenderSelectorTextField.text = GenderSelectorData[row]
} else if pickerView == HeightWholeNumberUnitSelectorPicker {
HeightWholeNumberUnitSelectorTextField.text = HeightWholeNumberUnitSelectorData[row]
} else if pickerView == HeightDecimalNumberUnitSelectorPicker {
HeightDecimalNumberUnitSelectorTextField.text = HeightDecimalNumberUnitSelectorData[row]
} else if pickerView == CurrentWeightWholeNumberUnitSelectorPicker {
CurrentWeightWholeNumberUnitSelectorTextField.text = CurrentWeightWholeNumberUnitSelectorData[row]
} else if pickerView == CurrentWeightDecimalNumberUnitSelectorPicker {
CurrentWeightDecimalNumberUnitSelectorTextField.text = CurrentWeightDecimalNumberUnitSelectorData[row]
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
if pickerView == GenderSelectorPicker {
return GenderSelectorData[row]
} else if pickerView == HeightWholeNumberUnitSelectorPicker {
return HeightWholeNumberUnitSelectorData[row]
} else if pickerView == HeightDecimalNumberUnitSelectorPicker {
return HeightDecimalNumberUnitSelectorData[row]
} else if pickerView == CurrentWeightWholeNumberUnitSelectorPicker {
return CurrentWeightWholeNumberUnitSelectorData[row]
} else if pickerView == CurrentWeightDecimalNumberUnitSelectorPicker {
return CurrentWeightDecimalNumberUnitSelectorData[row]
}
return ""
}
}
// Selectors End 1
}