add additional column to base kubectl get pods command - kubectl

im trying to build a custom column query that we use all the time. what i want is to take this basic output:
NAME READY STATUS RESTARTS AGE
mypod 2/2 Running 4 2d3h
and simply add a column to it, all i want is to add NODE:.spec.nodeName to this table. I can't find the base column format for the above, does anyone know where i can find it? I tried searching in the kubectl source code, but that proved to be a bit of a challenge.
Where can i find this output pattern?

You can use the tag --custom-columns in kubectl command to get the nodeName:
-o=custom-columns=<spec> Print a table using a comma separated list of custom columns
For example:
kubectl get pods my-pod -o=custom-columns='DATA:spec.nodeName' will return the node name.
Here you can find more about the tag and see usage examples.

Related

Gremlin - how to show field value instead label value

with gremlin I want to show a graph with vertex name a field name end not the label name.
How can do it?
If I use this
my graph
I see the label name and not a specific value field, for example Name field value
How I can modify my query?
Thanks a lot
I want a specific value field for vertex
That looks like you are using the graph-notebook Jupyter notebooks. You can use the -d and -de flags to tell the notebook how to label the diagram. For example:
%%gremlin -d name -de weight
will label nodes using a "name" property, and edges using a "weight" property.
Note that most of the magic commands, like %%gremlin support asking for help. You just need to put at least one character in the cell body. For example:
%%gremlin --help
x
There is additional documentation available here and here
There are also a number of sample notebooks that come included with the graph-notebook open source package. Several of those contain examples of how to customize graph visualizations. You may find those useful.

Maintain a audit table through re usable frame work

I was asked to create control table with Informatica. I am a newbie and do not have much knowledge about it. I saw the same kind of stuff in my previous project but don't know the way to create a mapplet for that. So the requirement is that I have to create a mapplet which has the following columns:
-mapping_name
-session_name
-last_run_date
--source count
--target count
--status
So what happens is
Example: We executed a workflow with a particular mapping last week.
Now after 1 week we are executing the same mapping.
The requirement is that we should be fetching only those records which fall in this particular time frame(i.e from previous run to the current run). This is something I do not know.
Can you please help me out? I can provide furthur details if required.
There is a solution provided in below link but it doesnt use mapplet.
See, if you want to use mapplet, you wont get 'status' attribute and mapplet approach can be difficult to implement for all mappings.
You can use this link to gather statistics as well.
http://powercenternotes.blogspot.com/2014/01/an-etl-framework-for-operational.html
Now, regarding your other requirement, it seems to me to be an issue with incremental extract. So, you need to store the date parameter when you ran your flow last - into a DB table or flat file.
Use that as reference and pull anything greater than that date.
Mapplet - We used this approach earlier to gather statistics. But this is difficult because you need to add this mapplet + a reusable generic target to capture stats.
Input -
Type_of_data- (this can be source, target)
unique_key - (unique key of the mapping)
MappingName - $PMMappingName
SessionName - $PMSessionName
Aggregator -
i/p-
Type_of_data
unique_key
MappingName group by
SessionName group by
o/p-
count_row = COUNT(*)
Output -
Type_of_data
MappingName
SessionName
count_row
Use a reusable generic target to capture all the rows. You need to add one set after each source, one set before each target. The approach in the link is better i think.

How to store the result of Google Dataproc query inside a variable GCP

I have a requirement wherein I need to count the number of records in a gcloud hive table and need to store this result inside a variable.
Below is the code for the same:
test=$(gcloud dataproc jobs submit hive --cluster=$CLUSTER --region=$REGION --execute="select count(*) from db.table;")
However, the above variable is not storing the count of records but is storing some logs which not useful for me.
Can please someone help me to find out how can we redirect the output of above query inside a variable.
The output of gcloud command actually consists of two parts: stderr and standard output. The output that includes count number is actually insided the stderr. The following command can do this trick,
cnt_output=$((gcloud dataproc jobs submit hive --cluster=$CLUSTER --region=$REGION --execute "select count(*) from db.table;" 1>/dev/null) 2>&1)
This basically strips the standout first and then convert the stderr to standard output so that it can be saved into a variable, i.e. cnt_output
After that you can use the tool mentioned in the answer above to capture the number you want.
My guess is the output you mention includes the logs for the Hive command and the output you want. It sounds like you just want the latter.
I'd recommend using something like grep, sed, or Python to capture the output. If you know regular expressions (regex), this should be pretty easy - this is a good example of what you might want to do. If you have not used regex before, a regex builder like this one will be useful.

How to select the 1st or last Element of a LIST column in Cassandra CQL?

I have a Cassandra table of files, similar to the following (fake) structure:
CREATE TABLE files{
filename: text;
versions:LIST<{timestamp, filesize}>
}
I carefully always insert the latest version at the beginning of the LIST.
And I tried to run
select filename, versions[0] from files;
I met the following error:
SyntaxException:
I couldn't find a solution on StackOverflow and Internet. Just wonder whether this is possible in Cassandra CQL? Of course, if there is no such a solution, I will process data at client side.
Thank you in advance,
Ying
The functionality is not yet available CASSANDRA-7396.
As of now you will have to fetch the complete list and filter it at application level.

Unix command in informatica

My Requirement is to get source counts,target counts and the rows that did not get changed that gets loaded via informatica.(Example:: Source::100, Target::50,Ignored(No change)::50)
I need to achieve this using presession and postsession command task.Can anyone help me with the scripts.
Thanks for the help in Advance
try to grep the information from the session log which gets created for every run. If you are still looking for the script, let me know.
example :
if you go to the bottom of the session log you see session load summary like below
SESSION LOAD SUMMARY
Output Rows [44768], Affected Rows [44768], Applied Rows [44768], Rejected Rows [0]
do cat log file name | grep 'Output Rows' in post session command
Why don't you use the metadata tables, write a Unix script on the infa server to get the count of SuccessfulRow count and all other counts you want from it and call it using postsession cmd which will also help you build an alert mechanism in for the number of count you get using mail -x. just see the below illustration.
Let me know if you need more details on this.
Short Answer: Refer to REP_SESS_Logs table in Informatica metadata repository Database.